69_LoVeRGuY's blog

By 69_LoVeRGuY, history, 3 years 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

| Write comment?
»
3 years 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.

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

    I can. This is the submission:

    Submission
»
3 years 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.

»
3 years 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.