Why it is not giving correct output?
Question in Description.
Why it is not giving correct output?
Question in Description.
I basically made 2 maps for inserting the characters.
One is map<char,int>
and other is map<char,bool> to check whether the character has appeared or not.
Then I simply start iterating in the string and printing the char with freq and also marking it as false in map 2 so I cannot print again.
Then What I did is I have a vector for this order in which I printed too.
So Like let’s take first case when value is 3.
I found 2 values which have freq as 3 and then have loop from first value till end.
And In loop I checked If freq of any char is less than 3 then I inserted it in front
Otherwise I inserted it in the last.
The front was working fine that Elements are getting inserted into front properly but it was creating issues in pushing back.
That’s why it was giving wrong output.
I hope You understand, If not I can explain in more detail or explain any part which you are not able to understand.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.