Random commentary about Machine Learning, BigData, Spark, Deep Learning, C++, STL, Boost, Perl, Python, Algorithms, Problem Solving and Web Search
Count how many every symbol occurs in set, then output required amount of ones, twos, threes and fours?
no additional space man
I was thinking about this: start from left and right and swap (2,3) on left with (0,1) on the right. After one pass we will have (0,1)s on the left and (2,3)s on the right. Then repeat same thing on these sub-arrays (swapping 1-0s and 3-2s). However I would need two indices.