Glossary: Coding Interviews in JavaScript
Two pointers
Also written: two-pointer
Pattern 9: keep two indexes, `left` at the front and `right` at the back of a sorted array, and move one inward each step. It gives O(n) time and O(1) space.
Glossary: Coding Interviews in JavaScript
Also written: two-pointer
Pattern 9: keep two indexes, `left` at the front and `right` at the back of a sorted array, and move one inward each step. It gives O(n) time and O(1) space.