Python two pointers


  • 0
    B
            left = 0
            right = len(numbers)-1
            while True:
                    if numbers[left] + numbers[right] > target:     
                            right -= 1
                    elif numbers[left] + numbers[right] < target:
                            left += 1
                    else:
                            return [left+1, right+1]
    

Log in to reply
 

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