69_LoVeRGuY's blog

By 69_LoVeRGuY, history, 8 days ago, In English

I was attempting the CSES Apartments problem and here is my solution in java. I've used the two pointer approach but still I have a timeout in one of the testcases. Someone please help me understand the shortcoming in my code.

Thanks in advance.

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it

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

We can't see that solution. If you go to the submission page, there is a blue button that says "Share code to others". If you hit that and copy the link, we can see the code.

  • »
    »
    8 days ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    I can. This is the submission:

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

Java is just slow, if you want AC use C++ but otherwise don't mind it since the CSES grader is naturally slow.

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

    Yes this happens to a couple of questions on CSES I guess when submitting in java. Thanks btw.

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

Have nobody taught you to not use Arrays.sort()? C'mon dude. Use Collections.sort() instead.

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

    I thought of it when I initially got only one timeout, but then I saw this. Your thoughts?? (Would help me learn something new maybe)