Given an array of 3 different colored balls, we have to sort it using minimum number of swaps. It could be done in O(n) using 3-pointers and two traversals(one to count no. of occurrences of each color and other to sort). Could this be implemented in one traversal(count is not known before).