Wed 3 Sep 2008
I had a friend send me a list of these questions today. some are repeats from previous posts but there are several new ones. Enjoy!
Logic Problems
a) 8 Steel balls, 1 heavier than all the rest. Use a Balance Scale to determine the heaviest ball in the shortest number of tries.
b) Find how many trailing zeroes are in the product of 100! (100 Factorial).
c) Replace each letter below with a corresponding number from 0 to 8. Each Letter can only be matched to one number (ie, all of the E’s would be a 3, and that would mean that no other Letter could be a 3). The following addition problem should work after you replace the letters.
S E V E N S E V E N + S I X ----------------------- T W E N T Y
Programming Problems
a) Write a function that takes an array of integers from 1 to 1 million, with one number being duplicated. Determine which integer is a duplicate, accounting for speed and efficiency.
b) Write a function that takes an array of integers from 1 to 1 million, with one number being missing from the range. Determine the missing integer, account for speed and efficiency.
c) Write a function that takes an array of an number of integers. Determine the largest contiguous sum, meaning given any two integers in the array, what is the highest sum? Given an array such as Array(1, -5, 3, -3, -9, 2) the highest contiguous sum would be 5.
d) Write a function that takes a string as a parameter and determine the first unique character in the string. In other words, given the string “sissy” the answer would be “i”. Afterwards, how would you optimize the function.
e) Pseudo-code the Ball Clock problem, determining how many cycles it takes for the balls to end up in the same position in the queue tray. Afterwards, how would you optimize the process if it were to be hit thousands of times on a given interface by thousands of users. If you have come up with a pure brute-force method, how could you optimize it further to shorten the processing time?
In the Programming Problems (a) and (b): Are the arrays in sorted or random order?
sorted