← ALL NOTES
Array

75. Sort Colors

Only three distinct values, so one pass with three pointers partitions the array into three zones: low (the boundary of 0s), mid (the scanner), and high (the boundary of 2s). The invariant: [0, low)…

Loading…