We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 862f76a commit 09bfbb3Copy full SHA for 09bfbb3
1 file changed
lkhyun/202510/13 PGM Lv2 이진 변환 반복하기.md
@@ -0,0 +1,25 @@
1
+```java
2
+class Solution {
3
+ static int convertCnt = 0;
4
+ static int zeroCnt = 0;
5
+ public int[] solution(String s) {
6
+ while(!s.equals("1")){
7
+ s = convertToBinary(s);
8
+ convertCnt++;
9
+ }
10
+ return new int[]{convertCnt,zeroCnt};
11
12
+ public String convertToBinary(String s){
13
+ String removedZero = s.replaceAll("0","");
14
+ int num = removedZero.length();
15
+ zeroCnt += s.length() - num;
16
+ StringBuilder sb = new StringBuilder();
17
+
18
+ while(num > 0){
19
+ sb.append(num%2);
20
+ num /= 2;
21
22
+ return sb.reverse().toString();
23
24
+}
25
+```
0 commit comments