@ its again the question related to the frequency..of number

My Approach would be
we have to count the no. of time the a particular number occurring in
the array  then first took the number which has lowest frequency in
case of Tie FCFS used up.
then proceed to higher frequency number that represents the continuous
chunks so that how much elements this chunks it has we can remove this
in a single click & so on....

so for this 3 1 2 1 4 3 1 2 1 4 3 2

here array of  4 elements
Elements    1 2 3 4   ///also lets say we are initializing the array
index as 1
Index          1 2 3 4
Frequency   4 3 3 2

we first process the 4      Click Required 1
then  2                           Click Required 1
then 3                            Click Required 1
then 1                            Click Required 1

Total  Click Required =4


so It Can be done in O(n) while space O(n) is penalty we have to pay
for it...more better approach will be appreciated

Correct me if you Find Approach is wrongs

Thanks & Regrads
Shashank Mani ""The best way to escape from a problem is to solve it."

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to