E.g. if array is of integer is given as 5 2 2 8 5 6 8 8, then we should get 8 8 8 5 5 2 2 6 , here freq. of 5 and 2 are same but 5 comes before 2 in array thus its should come before in output as well.
Here is the working code , let me know if it will fail for any test case and if we can improve it?
/********************************************************Time Complexity : O(n)+O(nlogn)+O(n)=O(nlogn)Space Complexity : Auxallery Space O(2n)= O(n)*********************************************************/Run Here http://ideone.com/FQ65xM