one line solution


  • 0
    T
    public class Solution {
        public bool HasAlternatingBits(int n) {
            return (((long)n + n/2+1) & ((long)n + n/2)) == 0;
        }
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.