4 line really simple python solution-beat 100% python submits


  • 0
    H

    I dont know whether this is considered cheating, but the speed is super fast

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


Log in to reply
 

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