Skip to content

Instantly share code, notes, and snippets.

function findOrderedPairs(arr: number[], sum: number) {
const result: number [][] = [];
arr.sort((a ,b) => a - b);
let low = 0, high = arr.length - 1;
while (low < high) {
if (arr[low] + arr[high] < sum) {
low++;
} else if (arr[low] + arr[high] > sum) {