3
aaaaabbbbb
aabbccc
bab
plzz tell me how is that possibleā¦ range of t is t<10^5 , so the data type of t should be long int, but in the following solution it is solved with āintā onlyā¦??
http://www.codechef.com/viewsolution/7017858
I have been getting a wrong answer for my code.
http://www.codechef.com/viewsolution/7019853
I would be glad if someone could give me a test case for which this fails.
Hereās what i did. I implemented a Heap whose where the first 2 highest values are constantly updated. This is essentially a greedy approach since i take the 2 largest. So if it were aaabbc. It would take a nd b whose occurences are 3 and 2. It would reduce them to 2 and 1 respectively and append the character to a string. Now the heap essentially consists of a(2) b(1) c(1). Now remove a and b and repeat. Now you have a(1),c(1). Append and done. Also, be careful when the size of the heap is 1. E.i only one character is left. You can add it only if the number of occurences of that character are 1 and the previuos value appended is not equal to this one.
can any one tell where i did wrongā¦
i am getting runtime error(nzec) but it is working good in my system for all casesā¦
http://www.codechef.com/viewsolution/7016382link text
@va1ts7_100 i hope you are confused. By the way range of int is ā2,147,483,648 to 2,147,483,647 .
@hello_all Your code is runing fine. here is the linklink text i donāt see why it was giving tle.
Anyways u can place your strlen() out of for loop because in every iteration it will be called.
can i know the cases where my code fails.have been getting wrong answer even though i have tried a similar approach. here is my sol link text
Getting wrong answer but not sure why ā¦Can anyone point out failing test case please
http://www.codechef.com/viewsolution/7021382
Help is appreciated !!
@Madhur . If you are saying changing System.out.print(new String(ans)) to System.out.println(new String(ans)) , I have already done that but still its not working .
Practice Link and Contest Link are swapped!
a test case where it fails?