class Solution { func isPowerOfTwo(_ n: Int) -> Bool { return log2(Double(n)) == floor(log2(Double(n))) } } // The solution above checks if the logarithm of n to the base 2 is an integer or not. If it is an integer, then n is a power of 2.

class Solution func isPowerOfTwo_ n Int - Bool 		return logn as! Doublelog2==logn as! Doublelog2 as! Int as! Double 运行错误、如果把as!换成as会编译错误

原文地址: https://www.cveoy.top/t/topic/ihdZ 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录