Colors: Blue = Left, Purple = Right, Orange = Legit, Red = Zero, Yellow = Moving, Green = Cleaned
Shuffle Left is a data cleanup algorithm that removes zeros from an array by shifting all non-zero elements to the left.
How it works:
Time Complexity: O(n²) - may need to shift elements multiple times
Scenario: A store has an inventory array where 0 represents sold-out items.
Before: [25, 0, 17, 0, 8, 0, 12, 0, 33]
After: [25, 17, 8, 12, 33]
The shuffle left algorithm efficiently removes the zeros, giving the store a clean list of items still in stock. This is faster than copying to a new array when you need to modify the original data in-place.
Benefits: In-place operation, no extra memory needed, predictable performance for cleanup operations