摘要:
一个整数为2的幂说明该整数的二进制中只有一个1. bool isSquareOf2 (int n){ return (n&(n-1))==0?true:false;} 阅读全文
摘要:
Description:Implement the following operations of a stack using queues.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the... 阅读全文
摘要:
Description:Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any posi... 阅读全文
摘要:
Description:Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as theHamming weight).For example, t... 阅读全文
摘要:
Description: Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7, 阅读全文