我的代码的渐近运行时复杂度是多少?

What is the asymptotic runtime complexity of my code?

下面是我的代码,我试图找出我的代码的渐近运行时复杂度,但我不确定

public static int myAlgorithm(List<Integer> myList) {
 if (myList.isEmpty()) {
 return 0;
    } 
 
Collections.sort(myList); // Can assume the sort algorithm is merge sort 

int sum = 0; 
int max = myList.get(myList.size() - 1); 
for (int item : myList) {
 int diff = Math.abs(max - item);
 sum = sum + diff; 
    } 
return sum; 
} 

假设你使用的排序是归并排序,算法的无症状运行时间是O(NlogN)

最复杂的步骤是排序步骤。

之后的代码大约是O(N);寻找最大值时 1 个循环和 1 个直通