Two Pointers
7 min · Dart examples
Walk two indices through a sorted array to find pairs or ranges in one pass.
Dart · Two Pointers0/5 cleared
Enemy 1 of 5
Two pointers keep a left and right index. On sorted arrays they often move inward: if the sum is too small, advance left; if too big, move right.
This avoids nested loops and runs in linear time after sorting.
You
Binary Treant
Loading editor...
Ln 1, Col 1Spaces: 4
Sign up to fightTarget output: pair