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 #2024_01_16_Time_320_ms_(58.62%)_Space_49.8_MB_(48.28%)
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
}
}