/**
 * Given a list of peak positions and a list of peak elevations, this function finds the highest peak
 * that is below the target elevation. It returns the position of the highest peak, or -1 if there is no peak
 * below the target elevation.
 *
 * @param peakPositions A list of integers representing the positions of the peaks.
 * @param peakElevations A list of integers representing the elevations of the peaks.
 * @param targetElevation An integer representing the target elevation.
 */
fun findHighestPeak(peakPositions: List<Int>, peakElevations: List<Int>, targetElevation: Int): Int {

    var highestPosition = -1
    var highestElevation = Int.MIN_VALUE

    for (i in peakPositions.indices) {
        if (peakElevations[i] < targetElevation && peakElevations[i] > highestElevation) {
            highestPosition = peakPositions[i]
            highestElevation = peakElevations[i]
        }
    }

    return highestPosition
}
/**
 * Given a list of peak positions and a list of peak elevations, this function finds the highest peak
 * that is below the target elevation. It returns the position of the highest peak, or -1 if there is no peak
 * below the target elevation.
 *
 * @param peakPositions A list of integers representing the positions of the peaks.
 * @param peakElevations A list of integers representing the elevations of the peaks.
 * @param targetElevation An integer representing the target elevation.
 */
fun findHighestPeak(peakPositions: List<Int>, peakElevations: List<Int>, targetElevation: Int): Int {
/**
 * Given a list of peak positions and a list of peak elevations, this function finds the highest peak
 * that is below the target elevation. It returns the position of the highest peak, or -1 if there is no peak
 * below the target elevation.
 *
 * @param peakPositions A list of integers representing the positions of the peaks.
 * @param peakElevations A list of integers representing the elevations of the peaks.
 * @param targetElevation An integer representing the target elevation.
 */
fun findHighestPeak(peakPositions: List<Int>, peakElevations: List<Int>, targetElevation: Int): Int {

    var highestPosition = -1
    var highestElevation = Int.MIN_VALUE

    for (i in peakPositions.indices) {
        if (peakElevations[i] < targetElevation && peakElevations[i] > highestElevation) {
            highestPosition = peakPositions[i]
            highestElevation = peakElevations[i]
        }
    }

    return highestPosition
}