g2901_3000.s2923_find_champion_i.Solution.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of leetcode-in-kotlin Show documentation
Show all versions of leetcode-in-kotlin Show documentation
Kotlin-based LeetCode algorithm problem solutions, regularly updated
package g2901_3000.s2923_find_champion_i
// #Easy #Array #Matrix #2023_12_31_Time_591_ms_(5.63%)_Space_49.8_MB_(36.62%)
class Solution {
fun findChampion(grid: Array): Int {
var champion = grid[1][0]
for (opponent in 2 until grid.size) {
if (grid[opponent][champion] != 0) {
champion = opponent
}
}
return champion
}
}