1class Solution {2 public:3 const static uint32_t a = 0b10101010101010101010101010101010;4 bool hasAlternatingBits(int n) {5 return ((a >> __builtin_clz(n)) ^ n) == 0;6 }7};
WPM •0 •0
ACC •0 •0
TIME •0