Showing posts with label Segregate 0s and 1s in an array by looping only once. Show all posts
Showing posts with label Segregate 0s and 1s in an array by looping only once. Show all posts

Segregate 0s and 1s in an array by looping only once

In this tutorial we see how to segregate 0s and 1s in an array just by looping only once, ie. O(n). With simple logic we will me maintaining 2 pointers like i and j...