Please subscribe to the official Codeforces channel in Telegram via the link: https://t.me/codeforces_official. ×

thor1234's blog

By thor1234, history, 12 days ago, In English,

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 :)

 
 
 
 
  • Vote: I like it  
  • +4
  • Vote: I do not like it  

»
12 days ago, # |
  Vote: I like it 0 Vote: I do not like it

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.

  • »
    »
    11 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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

    • »
      »
      »
      11 days ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      It's not because Java is slow. It's because there is a well-known way to break Arrays.sort specifically.

      • »
        »
        »
        »
        11 days ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        I had no idea about this , is it because of the dual pivot quicksort ? And would it have been different if I'd used Collections.sort() ? Thank you .

»
11 days ago, # |
  Vote: I like it 0 Vote: I do not like it

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.

  • »
    »
    11 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Thanks for your advice sir , I do solve problems but I don't know how to find that perfect balance of choosing something just above my level to make it challenging att the same time do-able , now it is either too easy like you said or too too hard . But I will keep solving and improving :)