Question: Sort an array of 0s, 1s and 2s in O(n) time and O(1) space.

Solution: Keep three variables for keeping count of 0's 1's and 2's.
Step 1: Traverse array and count 0's , 1's and 2's.
Step 2: Fill first 0's count number of places in array with 0 and so on.