JAVA_Binary Number with Alternating Bits_LeetCode 693 풀이 class Solution { public boolean hasAlternatingBits(int n) { String str = Integer.toBinaryString(n); for(int i = 0;i < str.length() - 1;i++){ if(str.charAt(i) == str.charAt(i + 1)) return false; } return true; } } * 출처 Binary Number with Alternating Bits - LeetCode Binary Number with Alternating Bits - Given a positive integer, check whether it has alternating bits: namely, if two adjacent bits will always have different values. Example 1: ...
#BinaryNumberwithAlternatingBits_LeetCode693
#JAVA
#JAVA_BinaryNumberwithAlternatingBits
#JAVA_BinaryNumberwithAlternatingBits_LeetCode693
#JAVA_LeetCode693
원문링크 : JAVA_Binary Number with Alternating Bits_LeetCode 693