Python 66ms solution using index


  • 0
    G
    class Solution:
        def search(self, nums, target):
            """
            :type nums: List[int]
            :type target: int
            :rtype: int
            """
            if target not in nums:
                return -1
            else:
                return nums.index(target)
    

Log in to reply
 

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