DSA Tutorial #14: Two Pointers and Sliding Window — Solve Array Problems in O(n)
Two pointers and sliding window are two of the most frequently tested techniques in coding interviews. They turn brute force O(n^2) solutions into elegant O(n) solutions. In this article, you will learn converging pointers, same-direction pointers, fast/slow pointers, and both fixed-size and variable-size sliding windows. We show core examples in Kotlin, Python, and Go. Two Pointers: Converging (Opposite Direction) Two pointers start at opposite ends of the array and move toward each other. ...
