Problem
You get an array of integers numbers and an integer target. The array is sorted: each item is equal to or larger than the item before it.
Find two items at different positions with the sum target. Exactly one such pair exists. Return the positions of the two items as [index1, index2], with index1 < index2.
The positions start at 1, not at 0. Your solution must use only O(1) extra space.
Example 1
- Input:
- numbers = [1,4,6,9,13], target = 15
- Output:
- [3,4]
- Explanation:
- The items at positions 3 and 4 are 6 and 9. Their sum is 15.
Example 2
- Input:
- numbers = [-5,-2,0,4], target = -2
- Output:
- [2,3]
- Explanation:
- The items at positions 2 and 3 are -2 and 0. Their sum is -2.
Example 3
- Input:
- numbers = [3,3,8], target = 6
- Output:
- [1,2]
- Explanation:
- Two items can have the same value.
Constraints
- 2 <= numbers.length <= 3 * 10^4
- -1000 <= numbers[i] <= 1000
- numbers is sorted in non-decreasing order.
- -1000 <= target <= 1000
- Exactly one pair of items has the sum target.
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
- Given a sorted integer array arr, two integers k and x, return the k closest integers to x in the array. The result should also be sorted in ascending order.
Coding
- Partition Array Into Two Arrays to Minimize Sum Difference
Coding · Array · Binary Search · Bit Manipulation
- Phone Screen: Two classic leetcode problems in the Top 30 list. One tests binary search in a sorted array, another one tests graph search using Breath First Search or Depth First Search algorithm
Coding
- Sum of Absolute Differences in a Sorted Array
Coding
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
Google
Leetcode 167. Two Sum II - Input Array Is Sorted
Reported Nov 7, 2025 · 1 source report
MID_LEVEL
Source snapshot: Nov 12, 2026
View source