// test20.cpp : 定义控制台应用程序的入口点. // include "stdafx.h" include include include include include include include include using namespace std; class Solution { public: int NumberOf1Between1AndN_Solution(int n) { // int num=1; int count = 0; for (int…
2014-05-03 22:10 题目链接 原题: Given a dictionary, and a list of letters ( or consider as a string), find the longest word that only uses letters from the string. [I didn't meet this question, what's the best solution?] 题目:给定一个字符串,和一个字典.从字典中找出一个最长的词,并且这个词…
2014-05-06 10:18 题目链接 原题: Given a ,) (,) (,), (,) should be returned. Some suggest to use Interval Tree to get this done in O(logn), but I did not understand how to construct and use the Interval Tree after reading its wiki page. Is there any other w…
原文:http://www.zhufengpeixun.cn/JavaScriptmianshiti/2014-04-01/287.html < script type = "text/javascript" > var x = 1; var y = 0; var z = 0; function add(n) { n = n + 1; } y = add(x); function add(n) { n = n + 3; } z = add(x); s = y + z; &l…
这是一道广为流传的google面试题.用最直观的方法求解并不是很难,但遗憾的是效率不是很高:而要得出一个效率较高的算法,需要比较强的分析能力,并不是件很容易的事情.当然,google的面试题中简单的也没有几道. 硬上:O(nlogn) int NumberOf1(unsigned int n); int NumberOf1Between1AndN_Solution1(unsigned int n) { ; ; i <= n; ++ i) number += NumberOf1(i); retur…