Snowflake·Software Engineer·Technical Phone Screen
- You're given a RecordCollection object with size(), getColor(i), and swap(i, j) as the only available operations. Each record has a color: 0 (Red), 1 (Green), or 2 (Blue). Sort the collection in place so all reds come first, then greens, then blues. Must run in O(n) time, O(1) space, single pass, no auxiliary arrays.
“The moment I saw the three-color constraint and single-pass requirement I knew it was the classic three-pointer partition problem.”