Solution in Python


  • 0
    Y
    def target(array, value):
            for i in array:
                    if i == value:
                            return array.index(value)
                            break
                    elif value < i:
                            return array.index(i)
                            break
                    elif value > i and array.index(i) is len(array)-1:
                            return len(array)
                            break
    

Log in to reply
 

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