一、题目描述 Write a function that takes an unsigned integer and returns the number of ’1 bits it has (also known as the Hamming weight). For example, the 32-bit integer ’11 has binary representation 00000000000000000000000000001011, so the function shou…
一、题目描述 Given an integer, write a function to determine if it is a power of three. Follow up: Could you do it without using any loop / recursion? 题目解读:写一个函数判断一个整数是否是3的幂数 进一步尝试不用任何循环/递归 思路:一开…
一、题目描述
Given an integer, write a function to determine if it is a power of two. 题目解读:判断一个整数是否是2的幂数 思路一:采用递归 c代码(8ms) class Solution {
public:bool isPowerOfTwo(int n) {if(n 1)retu…
一、题目描述 Given a sorted linked list, delete all duplicates such that each element appear only once. For example, Given 1->1->2, return 1->2. Given 1->1->2->3->3, return 1->2->3. 题目解读:将一条已排好序的链表中的重复…