All Downloads are FREE. Search and download functionalities are using the official Maven repository.

g2901_3000.s2951_find_the_peaks.Solution.kt Maven / Gradle / Ivy

There is a newer version: 1.32
Show newest version
package g2901_3000.s2951_find_the_peaks

// #Easy #Array #Enumeration #2024_01_16_Time_188_ms_(93.75%)_Space_37.5_MB_(72.50%)

class Solution {
    fun findPeaks(mountain: IntArray): List {
        val list: MutableList = ArrayList()
        for (i in 1 until mountain.size - 1) {
            if ((mountain[i - 1] < mountain[i]) && (mountain[i] > mountain[i + 1])) {
                list.add(i)
            }
        }
        return list
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy