mohitgupta943's blog

By mohitgupta943, history, 5 weeks ago, In English,

I wrote a program in java and python with same logic and complexity. i am getting tle in java code while python code is accepted pyhton:(https://codeforces.com/contest/1117/submission/50151786) java:(https://codeforces.com/contest/1117/submission/50150740) regarding question:(https://codeforces.com/contest/1117/problem/A) please help

 
 
 
 

»
5 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

This could be because of sort() and input methods.

  • »
    »
    5 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    but same thing i used in python too..

    • »
      »
      »
      5 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      You shouldn't use Array.sort() in Java; it can be

      O(n2)

      sometimes. Instead use Collections.sort() or shuffle your array before sorting