Two-pointer

2 articles

dsa5 min read

Summary Ranges — Linear Scan Two-Pointer [LC 228]

LeetCode 228 — asked at Amazon, Google, and Microsoft. Collapse a sorted unique integer array into the smallest list of ranges. Use a two-pointer linear scan to detect where consecutive runs break. O(n) time, O(1) space — clean and fast.

Read →