869. 重新排序得到 2 的幂 枚举排列,然后验证.比较暴力. 其实好一点的做法应该反过来,先把int范围下的2的N幂算出来,然后一个一个验证给出的数能不能拼成. class Solution { public Integer[] nextPermutation(Integer[] nums) { if (nums.length == 1) { return new Integer[]{}; } int p = -1; for (int i = nums.length - 2; i >= 0;…
Starting with a positive integer N, we reorder the digits in any order (including the original order) such that the leading digit is not zero. Return true if and only if we can do this in a way such that the resulting number is a power of 2. Example…
Implement pow(x, n), which calculates x raised to the power n (xn). Example 1: Input: 2.00000, 10 Output: 1024.00000 Example 2: Input: 2.10000, 3 Output: 9.26100 Example 3: Input: 2.00000, -2 Output: 0.25000 Explanation: 2-2 = 1/22 = 1/4 = 0.25 题意: 求…
问题 该文章的最新版本已迁移至个人博客[比特飞],单击链接 https://www.byteflying.com/archives/4058 访问. 给定一个整数 (32 位有符号整数),请编写一个函数来判断它是否是 4 的幂次方. 输入: 16 输出: true 输入: 5 输出: false 进阶:你能不使用循环或者递归来完成本题吗? Given an integer (signed 32 bits), write a function to check whether it is a po…
问题 该文章的最新版本已迁移至个人博客[比特飞],单击链接 https://www.byteflying.com/archives/3867 访问. 给定一个整数,写一个函数来判断它是否是 3 的幂次方. 输入: 27 输出: true 输入: 0 输出: false 输入: 9 输出: true 输入: 45 输出: false 进阶:你能不使用循环或者递归来完成本题吗? Given an integer, write a function to determine if it is a po…