Tap here to switch tabs
Problem
Submissions

Problem: Two Sum II - Input Array Is Sorted

med
30 min
Try to solve the Two Sum II - Input Array Is Sorted problem.

Statement

Given a 11 indexed array of integers numbers that is already sorted in non decreasing order, find two numbers such that they add up to a specific target number. Let these two numbers be numbers[index1] and numbers[index2] where 1≤extindex1<extindex2≤1 \leq ext{index1} < ext{index2} \leq numbers.length.

Return the indices of the two numbers, index1 and index2, as an integer array [index1, index2] of length 22.

Note: The tests are generated such that there is exactly one solution, and the same element cannot be used twice.

Constraints:

  • 2≤2 \leq numbers.length ≤3imes104\leq 3 imes 10^4

  • −1000≤-1000 \leq numbers[i] ≤1000\leq 1000

  • numbers is sorted in non decreasing order.

  • −1000≤-1000 \leq target ≤1000\leq 1000

  • The tests are generated such that there is exactly one solution.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Two Sum II - Input Array Is Sorted

med
30 min
Try to solve the Two Sum II - Input Array Is Sorted problem.

Statement

Given a 11 indexed array of integers numbers that is already sorted in non decreasing order, find two numbers such that they add up to a specific target number. Let these two numbers be numbers[index1] and numbers[index2] where 1≤extindex1<extindex2≤1 \leq ext{index1} < ext{index2} \leq numbers.length.

Return the indices of the two numbers, index1 and index2, as an integer array [index1, index2] of length 22.

Note: The tests are generated such that there is exactly one solution, and the same element cannot be used twice.

Constraints:

  • 2≤2 \leq numbers.length ≤3imes104\leq 3 imes 10^4

  • −1000≤-1000 \leq numbers[i] ≤1000\leq 1000

  • numbers is sorted in non decreasing order.

  • −1000≤-1000 \leq target ≤1000\leq 1000

  • The tests are generated such that there is exactly one solution.