You are viewing a single comment's thread. Return to all comments →
You initialize a biggest variable iterate the array once. When you've found a bigger one you change it accordingly. This is O(n).
biggest
O(n)
int biggest = Integer.MIN_VALUE; for(int i = 0; i < array.length; i++) { if(array[i] > biggest) biggest = array[i]; }
Insertion into a SortedSet is O(log n) (Source) and with n insertion this would be O(n * log n) which is asymptotically worse.
O(log n)
n
O(n * log n)
Seems like cookies are disabled on this browser, please enable them to open this website
Mini-Max Sum
You are viewing a single comment's thread. Return to all comments →
You initialize a
biggest
variable iterate the array once. When you've found a bigger one you change it accordingly. This isO(n)
.Insertion into a SortedSet is
O(log n)
(Source) and withn
insertion this would beO(n * log n)
which is asymptotically worse.