Cycle Sort in C++: Six LeetCode Array Problems That Are the Same Problem

Cycle sort on LeetCode is the pattern behind a group of array problems that look unrelated on the problem list and turn out to be the same eight lines of C++ with a different last paragraph. Six of them are below: 268, 448, 287, 645, 442, and 41. If you can write the skeleton from memory, you can solve all six, and the Hard one stops being a Hard. All the code here compiles and runs against the sample cases plus the edge cases listed at the bottom. More problems: the LeetCode series. The six problems at a glance # READ MORE