python very easy solution using enumerate

  • 0

    i cannot understand those most voted solutions, i don't this requires binary research

      def search(self, nums, target):
          for i,n in enumerate(nums):
                if n == target:
                    return i 
            return -1

    AC 36ms

Log in to reply

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