不得使用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.