how would you find maximum element in an array of numbers.
Sigiloso
Honestly, something like this is probably the best (assuming an unsorted array): int getBest(int[] nums){ int max; for(int i = 0; i max) max = curr; } return max; } You have to look at every element once, because if you skip an element you can't be sure it isn't the biggest. The lowest bound we can do is O(n). However, two loops makes this an O(n^2) problem, doing much more work without helping us solve the problem.