Mr.Awesome's blog

By Mr.Awesome, history, 8 years ago, In English

I was trying to solve this problem, after submitting my solution I got TLE and I couldn't figure out the problem with my O(n.log(n)) solution, I also checked some accepted solution and most of them are using the same approach?

my submission

UPD

I got accepted by copying someone sort function but I still want to know what's wrong with java.util.Arrays.sort function?

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

| Write comment?
»
8 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

probably because of sorting long integer array in Java, there was a post yesterday or a day before that about the same issue.

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

    I don't think so if you check my submissions, I used int array but also got TLE.

»
8 years ago, # |
  Vote: I like it +4 Vote: I do not like it

I have discussed about this already in this blog
Here is your AC code (Just shuffle the array before sorting)

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

    Thank's a lot, btw I also got AC by changing variables types to reference data types (long -> Long).