Move all zeros to front and ones to end maintaining relative order
Filed under Tejas Networks
The question
Given an array of random numbers consisting of 0s and 1s, rearrange the array such that all zeros are at the front and all ones are at the end while maintaining the relative order of elements. Time complexity must be O(n) and space complexity O(1).
No write-up yet. Related questions below have one.
Related Tejas Networks questions
Collected from public candidate posts and coding forums. Updated Nov 2026.