标签:cti while solution == tco min false rmi bsp
Given an integer, write a function to determine if it is a power of two.
class Solution { public: bool isPowerOfTwo(int n) { int num = 0; while (n > 0) { if (n &1) num++; n/=2; } if (num == 1) return true; return false; } };
标签:cti while solution == tco min false rmi bsp
原文地址:http://www.cnblogs.com/pk28/p/7291798.html