C# solution by binary operation


  • 0
    T
    public class Solution {
        public bool IsPowerOfFour(int num) {
                if (num == 1)
                    return true;
                string s = Convert.ToString(num, 2);
                if (s.Length % 2 == 1 && s[0] == '1' && Convert.ToInt32(s.Substring(1), 2) == 0)
                    return true;
                else
                    return false;
        }
    }
    

Log in to reply
 

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