Will Arrays.sort() increase time complexity and space time complexity?
问题 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 for loop to one pass loop, for example: public static int hello(int[]A){ Arrays.sort(A); for(int i=0;i<A.length;i++){ .................... } return ....; } So the loop will cost O(n) time. My question is: will Arrays.sort() cost more time? If I use Arrays.sort() , will this time complexity still be O(n)? And will Arrays.sort() cost more space?