I'm not all that proficient with Competitive Coding though I'd like to be .
I've been practising for some time now and before I struggled to solve 1 , now I solve 2 in contests and recently reached 3 star in Codechef
Started reading 10-20 pages of CLRS / Competitive Programmer's handbook every day
But sometimes the elegant solutions elude me . When I read the editorial I get it but don't know why I hadn't thought of it earlier and feel like I'll not get way better :/
Though my knowledge of data structures and algo are slowly improvin , I don't know how to hone my problem solving skills (I practise solvin')
And this is rare because my optimism never diminishes normally .
Have any of you faced this and how did you come out of this "code slump" and any tips on improving codin will be deeply appreciated ?
When normalcy is the only distinction in coding you feel you can reach not heights of greatness
And also , could anyone enlighten me on why my O(nlogn) solution in java failed :( : Subtraction
Thanks for your time , cp and the community are truly awesome :)
Even though I've never used Java, but from what I know, it might be some problem with the Arrays.sort() (could also be some anti-hashmap test cases). Reading from here, I changed the type of array uni from int to Integer in your solution, and it passed (but really close to the TL).
PS: I don't know much about Java, but I think the runtime could be reduced by handling the HashMap properly as the AC solution is still close to TL.
Oh , thank you :) But isn't the essence same for set in C++ or map in Python :( Why is Java pretty slow then because the logic doesn't differ so much in all implementations and getting a tle based on a lang is a bummer :'( I will try to handle the HashMap correctly in the future .
Thanks for your help
It's not because Java is slow. It's because there is a well-known way to break Arrays.sort specifically.
Solve more problems. Algorithms are great and all but the thing that holds people back is almost always problem solving. I'd even say the main function of algorithms is not applying them directly but only giving directions for thinking. I once did a writeup showing how rarely you need to apply any algorithms in Div2ABCD.
So how to train it? There is no way other than by doing it. You say you do it but are not improving? Maybe you solve problems that are too easy for you? Maybe you are reading the editorial too quickly. Give a problem more time. You probably know all the required concepts -- you just aren't able to put them together. Seeing someone else put them together is only marginally helpful.