Code
Loading editor...
Tap Analyze to see visualization
Click Analyze to visualize
See step-by-step execution, variables, and output
Variables
Run code to see variables
Output
Console output will appear here
Click Analyze to visualize
See step-by-step execution, variables, and output
Run code to see variables
Console output will appear here
Use a slow pointer to track the write position for kept elements. The fast pointer scans every element. When the fast pointer finds a value that is not the target, copy it to the slow position and advance slow.
The slow pointer only advances for non-target elements, effectively overwriting target values and compacting the remaining elements in-place.
Updated Feb 2026