Codeforces celebrates 10 years! We are pleased to announce the crowdfunding-campaign. Congratulate us by the link https://codeforces.com/10years. ×

mohitgupta943's blog

By mohitgupta943, history, 12 months 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

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

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

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

  • »
    »
    12 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    but same thing i used in python too..

    • »
      »
      »
      12 months 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