LeetCode_342 4的幂

给定一个整数 (32 位有符号整数),请编写一个函数来判断它是否是 4 的幂次方。
在这里插入图片描述

class Solution {
    public boolean isPowerOfFour(int num) {
        return Integer.toString(num,4).matches("^10*$");
    }
}
发布了250 篇原创文章 · 获赞 0 · 访问量 1230

猜你喜欢

转载自blog.csdn.net/qq_36198826/article/details/104024529