Skip to content

Commit faf33e9

Browse files
committed
1837
1 parent 48b3eb2 commit faf33e9

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
'''
3+
1. 아이디어 :
4+
k진수로 변환하고, 각 자리수를 더한다.
5+
6+
2. 시간복잡도 :
7+
o(log n)
8+
9+
3. 자료구조/알고리즘 :
10+
'''
11+
class Solution:
12+
def sumBase(self, n: int, k: int) -> int:
13+
s = ''
14+
while True:
15+
if n == 0:
16+
break
17+
r = n % k
18+
n = n // k
19+
s += str(r)
20+
21+
print(s)
22+
23+
return sum([int(i) for i in s])
24+

0 commit comments

Comments
 (0)