Simple Python Solution


  • 0
    T

    Chime in your feedback please

    class Solution(object):
        def search(self, nums, target):
            """
            :type nums: List[int]
            :type target: int
            :rtype: int
            """
            if not nums:
            	return -1
            else:
            	try:
           			i = nums.index(target)
           		except ValueError:
           			return -1
           		else:
           			return i

Log in to reply
 

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