不得使用timer之类的东西,只能靠一个场上跑来分名次。
20. Amazon: find BST of max size in a binary tree (should be a sub tree).
21. Microsoft: How do you implement a linked list without using dynamic memory allocation? use an array as a linked list.
22. Yahoo: 找出最长0,1对数相同的子串
eg. 01100111 --> 011001 110000011 --> 1100 / 0011
23. Yahoo: given a word,convert it into a pallindrome with minimum addition of letters to it. Letters can be added anywhere in the word.
if yahoo is given result should be yahoohay.
24. Amazon: Suppose you have a file on disk which does not fit in main memory, how will you sort it?
Optimizing time and the number of reads/writes. Mention exactly how many reads/writes you would need.
25. Google: given a 3 number discrete random number generator, how can you design a 5 number random generator?
What is the average number of trials necessary?
26. Google: 两个排序数组中求第k大的sum(a+b).
27. Amazon: 求一个数组的最大递增子序列(不要求连续).
28. Bloomberg: Write an algorithm to find the number of six digit numbers where the sum of the first three digits is equal to the sum of the last three digits.
29. Microsoft: 二维平面上给出一个多边形,按点的顺时针顺序表示,多边形可以是凸多边形也可以是凹多边形。 给出一个点,判断这个点是否在这个多边形内部.
30. Microsoft: 判断二叉树B是否为二叉树A的子结构,实现判断函数.
31. Google: 两个大小相同的排好序的数组,A和B,如何找出两个数组的中数.
32. Microsoft: 两个单项链表彼此相交,求他们第一个交节点.
33. Google: 在一个字符串中找到第一个只出现一次的字符。如输入abaccdeff,则输出b.
34. Microsoft: 找出带环单链表的环起始节点.
35. Anonymous: 以排好序的数组,找出数组最长等差数列的长度
eg. 1 3 5 6 8 9 10 12 13 14
最长等差数列为6 8 10 12 14
36. Google: Given an array of elements find the largest possible number that can be formed by using the elements of the array.
eg. 10 9->910 2 3 5 78->78532
37. Google: 两个数组,就地(不用额外空间)找出合并后第k大的数.
38. Microsoft: Write a function to validate a BST.
39. Facebook: Given an array of size n, find all the possible sub set of the array of size k(all the subsets must be of size k).
40. Microsoft: Given a BST, print all nodes lying between two values, inclusive of these values. Write test cases for same.
41. Google: 二维平面上有若干点,求出一条直线能穿越最多的点.
42. Microsoft: 找出BST上任意节点的下一个节点.
NODE* Next(NODE* pRoot, NODE* pToFind)
43. Google: 给定一个未排序数组,找出其中最长的等差数列. O(N*N)
44. Google: 在一个数组中寻找三个数,使得它们的和为0.
45. Amazon: 最简捷的方法判断一个数是否为2的幂.
46. Google: 两个排好序的数组A, B.和一个数c, 求a + b = c, a属于A, b属于B.
47. Google: given a number n... print a spiral matrix in O(1) space example if n=5 the op should be:
25 24 23 22 21
10 09 08 07 20
11 02 01 06 19
12 03 04 05 18
13 14 15 16 17
48. Amazon: given an array with positive and negative numbers find the first continuous subarray that sums to 0.
49. Adobe: Given an array A[i..j] find out maximum j-i such that A[i]<a[j] in O(n) time.
50. Facebook: 写一个自己的 double sqrt(double x), 满足一定精度就可以了.
51. Facebook: 反转单向链表.
52. Facebook: Write a Program to rotate a N * M matrix by 90 degrees.
53. Anonymous: 对于正数数组A[n], 找出A[i] = A[x]+A[y]的A[i]的最大值.
54. Anonymous: 有一个元素个数为2n的数组a,找出这样数量相等(均为n个元素)的两个子数组a1,a2, 使a1中所有元素的和sum1与a2中所有元素的和sum2的差值最小,即|sum1-sum2|最小.
55. Google: 给你一个32位的number,把它按位逆序 : 1101001 ==> 1001011.
56. Google: 一个range的序列,如[1,3], [2,6], [8,10],[15,18],写程序合并有重叠的range,比如上面的序列合并为[1,6], [8,10], [15,18].
57. Amazon: 将字符串abcde12345 inplace的转换为a1b2c3d4e5.
58. Google: 给一个整数,表示成n个整数的平方和,n最小, 求n.
eg. 10017 = 100^2 + 4^2 + 1 n = 3
59. Facebook: 实现atoi函数. 15min
60. Facebook: Implement division without using multiplication or division. It should work most efficient and fast.
61. Morgan Stanley: how to sort 100 numbers given using memory size sufficient for 20 elements only(like array of size 20)?
62. Facebook: How will you implement your own rand() such that it returns an integer from 0 to n-1 with equal probability?
63. Linkedin: Write a function that would return the 5th element from the tail (or end) of a singly linked list of integers, in one pass, and then provide a set of test cases against that function (please do not use any list manipulation functions that you do not implement yourself).
64. Amazon: Design an OO parking lot.What classes and functions will it have. It should say, full, empty and also be able to find spot for Valet parking.The lot has 3 different types of parking: regular, handicapped and compact.
65. Amazon: Given 2 rectangles with top left and bottom right coordinates for each rectangle, return 1 if they have a common area otherwise return -1.