From 2f55b64665fd196fe47c0d92374c58bf230dff85 Mon Sep 17 00:00:00 2001 From: LiiNi-coder <97495437+LiiNi-coder@users.noreply.github.com> Date: Wed, 17 Dec 2025 23:59:17 +0900 Subject: [PATCH] =?UTF-8?q?[20251217]=20PGM=20/=20LV2=20/=202=EA=B0=9C=20?= =?UTF-8?q?=EC=9D=B4=ED=95=98=EB=A1=9C=20=EB=8B=A4=EB=A5=B8=20=EB=B9=84?= =?UTF-8?q?=ED=8A=B8=20/=20=EC=9D=B4=EC=9D=B8=ED=9D=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\353\245\270 \353\271\204\355\212\270.md" | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 "LiiNi-coder/202512/17 PGM 2\352\260\234 \354\235\264\355\225\230\353\241\234 \353\213\244\353\245\270 \353\271\204\355\212\270.md" diff --git "a/LiiNi-coder/202512/17 PGM 2\352\260\234 \354\235\264\355\225\230\353\241\234 \353\213\244\353\245\270 \353\271\204\355\212\270.md" "b/LiiNi-coder/202512/17 PGM 2\352\260\234 \354\235\264\355\225\230\353\241\234 \353\213\244\353\245\270 \353\271\204\355\212\270.md" new file mode 100644 index 00000000..894db07b --- /dev/null +++ "b/LiiNi-coder/202512/17 PGM 2\352\260\234 \354\235\264\355\225\230\353\241\234 \353\213\244\353\245\270 \353\271\204\355\212\270.md" @@ -0,0 +1,40 @@ +```java +import java.util.*; + +class Solution { + public long solution(long[] numbers) { + ArrayList answers = new ArrayList<>(); + + for(long num: numbers){ + long now = num + 1; + while(true){ + if(isOneOrTwoDifference(num, now)){ + answers.add(now); + break; + } + now++; + } + } + return answers.stream() + .mapToLong(Long::longValue) + .toArray(); + } + + private boolean isOneOrTwoDifference(long a, long b){ + long diff = a ^ b; + int count = 0; + while(diff > 0){ + if((diff & 1) == 1){ + count++; + } + if(count > 2){ + return false; + } + + diff >>= 1; + } + return true; + } +} + +```