0

以下问题的大 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;
    }
} 
4

1 回答 1

3

It's O(n), since it loops the array only once.

于 2013-02-11T07:53:43.427 回答