posted @ 2016-04-05 03:06 CSU蛋李 阅读(143) 评论(0) 推荐(0) 编辑
摘要:
Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), retur 阅读全文
摘要:
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 阅读全文
posted @ 2016-04-05 02:22 CSU蛋李 阅读(77) 评论(0) 推荐(0) 编辑
摘要:
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping yo 阅读全文
posted @ 2016-04-05 02:12 CSU蛋李 阅读(133) 评论(0) 推荐(0) 编辑
摘要:
春节期间小明使用微信收到很多个红包,非常开心。在查看领取红包记录时发现,某个红包金额出现的次数超过了红包总数的一半。请帮小明找到该红包金额。写出具体算法思路和代码实现,要求算法尽可能高效。 给定一个红包的金额数组gifts及它的大小n,请返回所求红包的金额。 测试样例: 阅读全文
posted @ 2016-04-01 13:00 CSU蛋李 阅读(167) 评论(0) 推荐(0) 编辑
摘要:
当n=1时,“0”,“1”; 当n=2时,“00”,“01”,“11”,“10“; 当n=3时,“000”,“001”,“011”,“010”,“110”,“111”,“101”,“100”; 由此可以看出,每次向下递归调用时,总是在原来的字符串的基础上加“0”,“1”,“1”,“0“,”0“,”1 阅读全文
posted @ 2016-04-01 12:37 CSU蛋李 阅读(209) 评论(0) 推荐(0) 编辑
摘要:
Write an algorithm to determine if a number is "happy". A happy number is a number defined by the following process: Starting with any positive intege 阅读全文
posted @ 2016-04-01 01:07 CSU蛋李 阅读(118) 评论(0) 推荐(0) 编辑
摘要:
Remove all elements from a linked list of integers that have value val. ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 -- 阅读全文
posted @ 2016-04-01 00:35 CSU蛋李 阅读(103) 评论(0) 推荐(0) 编辑
摘要:
// 10.3.2.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include #include #include #include using namespace std; string & make_plural(int cnt, string &str) { str=cnt > 1 ? (str + "s") : str; ... 阅读全文
posted @ 2016-03-31 22:01 CSU蛋李 阅读(98) 评论(0) 推荐(0) 编辑