167. Two Sum II - Input Array Is Sorted
Medium
Problem:
Input: numbers = [2,7,11,15], target = 9
Output: [1,2]
Explanation: The sum of 2 and 7 is 9. Therefore, index1 = 1, index2 = 2. We return [1, 2].What to learn:
Slicing
>>> a = [x for x in range(100000000)]
>>> id(a)
4376898632
>>> b = a
>>> id(b)
4376898632
>>> c= a[:]
>>> id(b)
4377566600Solution:
Two Pointers
Binary Search
bisect Module without Slicing
bisect Module without SlicingLast updated