0% found this document useful (0 votes)
28 views

Challenge: Find Minimum in Subarray: Python C++ JS

The document describes finding the minimum value in a subarray of an input array. It provides a function called indexOfMinimum that takes an array and a starting index as parameters. The function returns the index of the smallest value occurring at or after the starting index in the array. If the smallest value occurs multiple times, it returns the index of the leftmost occurrence.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Challenge: Find Minimum in Subarray: Python C++ JS

The document describes finding the minimum value in a subarray of an input array. It provides a function called indexOfMinimum that takes an array and a starting index as parameters. The function returns the index of the smallest value occurring at or after the starting index in the array. If the smallest value occurs multiple times, it returns the index of the leftmost occurrence.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Challenge: Find minimum in Subarray

Finish writing the function indexOfMinimum, which takes an array and a


number startIndex, and returns the index of the smallest value that occurs
with index startIndex or greater. If this smallest value occurs more than once
in this range, then return the index of the leftmost occurrence within this
range.

Java Python C++ JS

class Solution {
public static int indexOfMinimum(int[] array, int startIndex) {
// Set initial values for minValue and minIndex,
// based on the leftmost entry in the subarray:
int minValue = array[startIndex];
int minIndex = startIndex;

// Loop over items starting with startIndex,


// updating minValue and minIndex as needed:

return minIndex;
}
}

You might also like