From 09bfbb3fd033d9dfe5d2ec2a2f6d4e5a44653ab0 Mon Sep 17 00:00:00 2001 From: lkhyun <102892446+lkhyun@users.noreply.github.com> Date: Mon, 13 Oct 2025 13:06:25 +0900 Subject: [PATCH] =?UTF-8?q?[20251013]=20PGM=20/=20Lv2=20/=20=EC=9D=B4?= =?UTF-8?q?=EC=A7=84=20=EB=B3=80=ED=99=98=20=EB=B0=98=EB=B3=B5=ED=95=98?= =?UTF-8?q?=EA=B8=B0=20/=20=EC=9D=B4=EA=B0=95=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...30\353\263\265\355\225\230\352\270\260.md" | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 "lkhyun/202510/13 PGM Lv2 \354\235\264\354\247\204 \353\263\200\355\231\230 \353\260\230\353\263\265\355\225\230\352\270\260.md" diff --git "a/lkhyun/202510/13 PGM Lv2 \354\235\264\354\247\204 \353\263\200\355\231\230 \353\260\230\353\263\265\355\225\230\352\270\260.md" "b/lkhyun/202510/13 PGM Lv2 \354\235\264\354\247\204 \353\263\200\355\231\230 \353\260\230\353\263\265\355\225\230\352\270\260.md" new file mode 100644 index 00000000..30e150ea --- /dev/null +++ "b/lkhyun/202510/13 PGM Lv2 \354\235\264\354\247\204 \353\263\200\355\231\230 \353\260\230\353\263\265\355\225\230\352\270\260.md" @@ -0,0 +1,25 @@ +```java +class Solution { + static int convertCnt = 0; + static int zeroCnt = 0; + public int[] solution(String s) { + while(!s.equals("1")){ + s = convertToBinary(s); + convertCnt++; + } + return new int[]{convertCnt,zeroCnt}; + } + public String convertToBinary(String s){ + String removedZero = s.replaceAll("0",""); + int num = removedZero.length(); + zeroCnt += s.length() - num; + StringBuilder sb = new StringBuilder(); + + while(num > 0){ + sb.append(num%2); + num /= 2; + } + return sb.reverse().toString(); + } +} +```