Sir, I would say that instead of posting code, if you can explain your approach/algo or include some comments in your code as such what that statement/variable/loop is doing, we will be able to help you better.
Because coding is quite weird in this sense. A programmer wouldn’t be able to understand HIS OWN code if he sees it after a month, (he wont be able to deduce what he did or thought while writing it if he includes no comment.)
Don’t take it in wrong sense, I admire your dedication to solving this problem alone for this long! Its really nice! But I would say, if you explain your approach, we might be able to give you the correct deductions/logic or even a correct code which will help you learn.
Cause if you get stuck with a problem, then its bad! It will take your time where you could solve many more problems which would make you learn many more things!
So, I will request, that if you find it agreeable, please explain how you are approaching the problem.
I ran your code on hackerrank compiler (cause idk why codechef still gave me errors. Worked on hackerrank tho) and what I saw was-
For inputs <= 10^9, code worked all fine.
But when I entered 10^10 -
Runtime error
Input (stdin)
1
8 2
10000000000 25 25 30 30 30 30 25
Your Output
~ no response on stdout ~
Error
Exception in thread "main" java.lang.NumberFormatException: For input string: "10000000000"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:583)
at java.lang.Integer.parseInt(Integer.java:615)
at Main.main(Main.java:26)
I will say that take some time off this problem, and solve some other. Because the key points of problem sometimes strike randomly. Don’t stress over it dear!
@jawa2code Its very unlikely that in codechef’s official contests test case are wrong so it’s much better to validate your code on different test cases before arguing and blaming someone.
Exactly! Posting a code like that doesn’t seem to be good. Even the solutions of all programmers has been out then he can take a estimation about why and where his code is failing.
See if someone could not debug their own code then how can he/she survive in industry where he/she deals with such a large amount of codes.
@bansal1232 - I think you misunderstood where I meant “A programmer wouldn’t be able to understand HIS OWN code if he sees it after a month” , perhaps I should had worded it better.
I simply meant to imply that, at least at this stage (where we are learning coding), we sometimes just…forget what we did or thought while solving the question XD.
I am sorry if it sounds confusing. I just wanted to imply that comments or telling approach is appreciated when requesting others to check your code. (thanks for pointing out the ambiguity of my statement tho!)
oh please stop spamming the discussion session. If he is not replying then may be the reason is that he is busy in other stuff and have not seen that message. So i request you to be please be patience.
is it just me or that code just doesn’t compile on codechef ide…I tried removing blank space and stuff. It says " > expected" in each of-
TreeMap<String, Integer> table = new TreeMap<String, Integer>();
HashMap<Integer, Integer> reqCntTable = new HashMap<Integer, Integer>();