Rearrange Array Elements with Zeros at End
Filed under SAP
The question
Write a function to rearrange elements of an array so that all 0s are at the end and all non-zero elements are at the front while maintaining the internal order, using O(1) auxiliary space and O(n) time complexity.
No write-up yet. Related questions below have one.
Related SAP questions
Collected from public candidate posts and coding forums. Updated Nov 2026.