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
- database
- string
- SQL
- Number Theory
- hash table
- 구현
- Tree
- dynamic programming
- greedy
- Counting
- sorting
- 코테
- java
- Stack
- 코딩테스트
- Math
- Binary Search
- Class
- 파이썬
- Binary Tree
- implement
- Matrix
- geometry
- two pointers
- Method
- array
- simulation
- Data Structure
- bit manipulation
- 자바
Archives
- Today
- Total
코린이의 소소한 공부노트
[LeetCode/Medium] 1689. Partitioning Into Minimum Number Of Deci-Binary Numbers 본문
코딩테스트 풀이/JAVA
[LeetCode/Medium] 1689. Partitioning Into Minimum Number Of Deci-Binary Numbers
무지맘 2023. 1. 15. 22:591. Input
1) 정수를 나타내는 문자열 n
2. Output
1) n을 최소한의 deci-binary의 합으로 나타내려고 할 때 필요한 deci-binary의 수
- deci-binary란 11, 101, 1000과 같이 1과 0으로 이루어진 10진수를 말한다.
3. Constraint
1) 1 <= n.length <= 10^5
2) n은 숫자로만 이루어져 있다.
3) n에는 불필요한 0은 없으며, n이 나타내는 숫자는 자연수이다.
4. Example
Input: n = "32" -> Output: 3
설명: 10 + 11 + 11 = 32이므로 최소 3개가 필요하다. 따라서 3을 반환한다. 이것 외에는 3개보다 더 많은 수가 필요하므로 답이 될 수 없다.
5. Code
1) 첫 코드(2022/06/27)
char max = 0;
for(int i=0 ; i<n.length() ; i++)
if(n.charAt(i) > max)
max = n.charAt(i);
return max - '0';
'코딩테스트 풀이 > JAVA' 카테고리의 다른 글
[LeetCode/Easy] 2180. Count Integers With Even Digit Sum (0) | 2023.01.15 |
---|---|
[LeetCode/Easy] 2176. Count Equal and Divisible Pairs in an Array (0) | 2023.01.15 |
[LeetCode/Easy] 2169. Count Operations to Obtain Zero (0) | 2023.01.13 |
[LeetCode/Easy] 2160. Minimum Sum of Four Digit Number After Splitting Digits (0) | 2023.01.13 |
[LeetCode/Easy] 2154. Keep Multiplying Found Values by Two (0) | 2023.01.13 |