2014-05-08 08:26 题目链接 原题: Given a preorder traversal, create a binary search tree in optimized time 题目:给定一个二叉搜索树的前序遍历,请重建这棵树.要求最优化算法. 解法1:这人每次出题都要求“最优算法”,自己写的代码却实在让人汗颜,让人觉得这家伙就是懒得思考,想从别人那儿问答案.前序遍历的顺序是“根左右”,那么根节点之后所有小于根的部分就是左子树,后面就是右子树了.怎么找这条分界线呢?可以顺着…
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-08 23:45 题目链接 原题: How would you use Dijkstra's algorithm to solve travel salesman problem, which is to find a shortest path from a starting node back to the starting node and visits all other node exactly once. 题目:如何用Dijkstra算法来解决TSP问题?(谁会出这种…
2014-05-08 21:33 题目链接 原题: largest number that an int variable can fit given a memory of certain size 题目:给定特定内存大小,请问int型的变量能表示的最大整数是多少? 解法:这个“Guy”出的题目总是这样表意不清.特定大小的内存是什么意思?他要说的是字长吧?16位int占两字节,32位以后int都占四字节.这样能表示的最大整数就是(1 << sizeof(int) * 8  - 1) - 1.…
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…
2014-05-06 07:11 题目链接 原题: Find a shortest path ,) to (N,N), assume is destination, use memorization to cache the result. Here is my code. I am not sure if I am caching it right. 题目:给定一个N * N的矩阵,找出从(0, 0)到(n - 1, n - 1)的最短路径.此人在后面还贴上了自己的代码,从代码水平上看此人实力…
2014-05-08 23:18 题目链接 原题: If you have data coming in rapid succession what is the best way of dealing with redundant data? 题目:如果你有大量数据流入,如何处理冗余数据? 解法:又是“Guy”出的题,题意不清,没有情景.神马意思?做个Cache吧. 代码: // http://www.careercup.com/question?id=5680330589601792 //…
2014-05-08 22:55 题目链接 原题: Given a list of strings. Produce a list of the longest common suffixes. If it asks for longest common substring, then building a suffix tree should be the way to go. But how should we implement this if it is for longest comm…
2014-05-08 22:42 题目链接 原题: How would you split a search query across multiple machines? 题目:如何把一个搜索query分发到多个机器上? 解法:又是“Guy”出的题目.对query字符串算取数字签名,然后对集群的机器数量取模,就可以得到对应落在的机器了. 代码: // http://www.careercup.com/question?id=5377673471721472 // Answer: // The…
2014-05-08 22:27 题目链接 原题: What's the tracking algorithm of nearest location to some friends that are located in a grid region? 题目:在一个格点坐标的地图里,如何追踪到一个朋友附近最近的地标? 解法:我都不知道怎么翻译,这又是“Guy”出的一道莫名其妙的题目.但你不断遇到这种不知所云的题目时,很容易情绪暴躁.You just don't argue with a jerk…