kt: add «3396. Minimum Number of Operations to Make Elements in Array Distinct»

URL:	https://leetcode.com/problems/minimum-number-of-operations-to-make-elements-in-array-distinct/
Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
Matej Focko 2025-04-08 19:49:10 +02:00
parent b117d385e9
commit e95583b334
Signed by: mfocko
SSH key fingerprint: SHA256:icm0fIOSJUpy5+1x23sfr+hLtF9UhY8VpMC7H4WFJP8

View file

@ -0,0 +1,15 @@
class Solution {
fun minimumOperations(nums: IntArray): Int =
BooleanArray(101).let { seen ->
for (num in nums.withIndex().reversed()) {
when (seen[num.value]) {
true -> {
return num.index / 3 + 1
}
else -> seen[num.value] = true
}
}
0
}
}