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

Method getMinIndex

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

Source from the content-addressed store, hash-verified

5public class SwapMinMax {
6
7 public static int getMinIndex(int[] array) {
8 int minIndex = 0;
9 for (int i = 1; i < array.length; i++) {
10 if (array[i] < array[minIndex]) {
11 minIndex = i;
12 }
13 }
14 return minIndex;
15 }
16
17 public static int getMaxIndex(int[] array) {
18 int maxIndex = 0;

Callers 1

swapMinMaxBetterMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected