Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
以下问题的大 O 是多少?
public static void mystery(int[] list) { for (int i = 0; i < list.length/2; i++) { int j = list.length-1-i; int temp = list[i]; list[i] = list[j]; list[j] = temp; } }
It's O(n), since it loops the array only once.