Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
Tags
- Counting
- geometry
- array
- simulation
- bit manipulation
- SQL
- Tree
- Class
- 구현
- greedy
- Number Theory
- implement
- Matrix
- java
- Data Structure
- Method
- 코테
- 코딩테스트
- Math
- 파이썬
- sorting
- Stack
- dynamic programming
- two pointers
- Binary Search
- string
- database
- Binary Tree
- hash table
- 자바
Archives
- Today
- Total
코린이의 소소한 공부노트
[LeetCode/Easy] 1837. Sum of Digits in Base K 본문
1. Input
1) 정수 n
2) 정수 k
2. Output
1) 10진수 n을 k진수로 바꿨을 때, 자릿수의 합을 반환
3. Constraint
1) 1 <= n <= 100
2) 2 <= k <= 10
4. Example
Input: n = 34, k = 6 -> Output: 9
설명: 34 = 6*5 + 4 이므로 6진수로 바꾸면 54가 된다. 따라서 5 + 4 = 9를 반환한다.
5. Code
1) 첫 코드(2022/06/15)
int sum = 0;
while(n>=1){
sum += n%k;
n /= k;
}
return sum;
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[LeetCode/Easy] 21. Merge Two Sorted Lists (0) | 2023.01.05 |
---|---|
[LeetCode/Easy] 1844. Replace All Digits with Characters (0) | 2023.01.05 |
[LeetCode/Easy] 1832. Check if the Sentence Is Pangram (0) | 2023.01.05 |
[LeetCode/Easy] 1827. Minimum Operations to Make the Array Increasing (0) | 2023.01.05 |
[LeetCode/Easy] 1822. Sign of the Product of an Array (0) | 2023.01.05 |