Two Sum II (Sorted Input)
Easy๐ท๏ธ Two pointers๐ Two Pointers & Sliding Window
๐งฉ The problem
The array is sorted in increasing order. Return the 1-based positions [i, j] of the two numbers that add up to the target, using O(1) extra space.
Examples
[2, 7, 11, 15], 9 โ [1, 2]
๐ฏ Aim for: O(n) time ยท O(1) space
โ๏ธ Write your solution
Pick a language, press Run to try it, then Run tests to check it against every test case โ just like a coding interview.