MCPcopy Create free account
hub / github.com/careercup/ctci / getMaxIndex

Method getMaxIndex

java/Introduction/SwapMinMax/SwapMinMax.java:17–25  ·  view source on GitHub ↗
(int[] array)

Source from the content-addressed store, hash-verified

15 }
16
17 public static int getMaxIndex(int[] array) {
18 int maxIndex = 0;
19 for (int i = 1; i < array.length; i++) {
20 if (array[i] > array[maxIndex]) {
21 maxIndex = i;
22 }
23 }
24 return maxIndex;
25 }
26
27 public static void swap(int[] array, int m, int n) {
28 int temp = array[m];

Callers 1

swapMinMaxBetterMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected