C# o(1) with loop


  • 0
    P
    public class Solution {
        public bool IsPowerOfFour(int num) {
            int beitai = 1;
            for(int i = 0;i<16;i++){
                if(num == beitai)
                    return true;
                beitai <<=2;
            }
            return  false;
        }
    }

Log in to reply
 

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