LeetCode 167 Two Sum II Input array is sorted

LeetCode 167 Two Sum II Input array is sorted Problem

Download Code
class Solution(object):
    def twoSum(self, numbers, target):
        """
        :type numbers: List[int]
        :type target: int
        :rtype: List[int]
        """
        # Two Points
        begin, end = 0, len(numbers) - 1
        while begin < end:
            curr = numbers[begin] + numbers[end]
            if curr == target:
                return [begin + 1, end + 1]
            elif curr < target:
                begin += 1
            else:
                end -= 1

Download Two Sum II Input array is sorted.py

List of all Two Sum II Input array is sorted problems

Leetcode 167 Two Sum II Input array is sorted problem solution in python3 with explanation. This is the best place to expand your knowledge and get prepared for your next interview.

Feedback is the most important part of any website.

If you have any query, suggestion or feedback, Please feel free to contact us.