When the sum is too small, moving right down makes it smaller still.
Acceptance criteria
- 1.#out should show 2-3.
When the sum is too small, moving right down makes it smaller still.
function twoSumSorted(sorted, target) { let left = 0, right = sorted.length - 1; while (left < right) { const sum = sorted[left] + sorted[right]; if (sum === target) return [left, right]; if (sum < target) right--; else right--; } return ["no", "pair"]; } document.querySelector('#out').textContent = twoSumSorted([1, 3, 4, 6, 8, 11], 10).join("-");
Output ready when you are
Press Run to render your code, or Submit to validate your solution.