Given an array of integers and two bounds, low and high, partition the array into three segments. The first segment should contain all elements less than low, the second segment should contain all elements equal to or greater than low but less than or equal to high, and the third segment should contain all elements greater than high.
Explanation: The elements less than 4 are 1, 2, and 3. The elements greater than or equal to 4 but less than or equal to 6 are 4, 6, and 5. The elements greater than 6 are 7, 8, and 9.
Explanation: The elements less than 35 are 10, 20, and 30. The elements greater than or equal to 35 but less than or equal to 45 are 40. The elements greater than 45 are 50 and 60.
Three-way partitioning
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak