kt: add «1780. Check if Number is a Sum of Powers of Three»

URL:	https://leetcode.com/problems/check-if-number-is-a-sum-of-powers-of-three/
Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
Matej Focko 2025-03-04 09:38:55 +01:00
parent 9eff71a1a7
commit 513547c2f2
Signed by: mfocko
SSH key fingerprint: SHA256:icm0fIOSJUpy5+1x23sfr+hLtF9UhY8VpMC7H4WFJP8

View file

@ -0,0 +1,15 @@
class Solution {
fun checkPowersOfThree(n: Int): Boolean {
var n = n
while (n > 0) {
if (n % 3 > 1) {
return false
}
n /= 3
}
return true
}
}