5 lines python solution (beats 80%)

  • 0
    class Solution(object):
        def search(self, nums, target):
            :type nums: List[int]
            :type target: int
            :rtype: int
            l = len(nums)
            for i in range(l):
                if nums[i] == target:
                    return i
            return -1

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.