There is an array related problem, the requirement is that time complexity is O(n) and space complexity is O(1).
If I use Arrays.sort(arr), and use a
According to the java jvm 8 javadocs of Arrays.sort() method:
The sorting algorithm is a Dual-Pivot Quicksort by Vladimir Yaroslavskiy, Jon Bentley, and Joshua Bloch. This algorithm offers O(n log(n)) performance on many data sets that cause other quicksorts to degrade to quadratic performance, and is typically faster than traditional (one-pivot) Quicksort implementations.
So it will increase your time complexity from O(n) to O(n log(n))