| https://leetcode.com/problems/find-the-town-judge/ | Easy |
|---|
class Solution {
fun findJudge(n: Int, trust: Array<IntArray>): Int {
val trustScores = IntArray(n + 1)
for ((a, b) in trust) {
trustScores[a]--
trustScores[b]++
}
for (i in 1..n) {
if (trustScores[i] == n - 1) {
return i
}
}
return -1
}
}