Where do I start?
Topcoder is a good resource for diving right in – they host weekly contests (including a rating system that allows you to track your progress) and keep an archive of past contests that you can work through on your own time.
If you don’t fancy the idea of competing in a live contest, there are also some good online problem archives. The Sphere Online Judge maintains a huge problem set that lets you submit your code to an automated judge, allows you to write your solutions in over 40 different languages, and runs a forum where you can discuss problems with other users.
If you’re still in school, the gold standard for programming contests is probably the International Collegiate Programming Contest (ICPC) run by the Association for Computing Machinery (ACM). Every year the ICPC hosts regional contests around the world, and then sends the winners of all the regional contests to their world finals. If you’re lucky enough to attend a college with an ICPC club that hosts regular practice contests, consider joining. Or if your school doesn’t have such a club, maybe you can start one.
You also might want to check out Facebook’s very own programming competition, the Hacker Cup. The top 25 finalists get flown out to our Menlo Park campus to compete in the finals, and the winner gets $10k. Not a bad way to brush up on your algorithm skills!
The following is a list of questions that are compiled from previous years interviewee and online forums. try solving these before jumping for the interview. Best of Luck!
Q1. Calculate the square root of a double?
Q2. Given n intervals [si, fi], find the maximum number of overlapping intervals.
Q3. Print all the paths from root to every leaf in a binary tree.
Q4. Print the sum of all the numbers at every vertical level in a binary tree
Q5. Given a set of n jobs with [start time, end time, cost] find a subset so that no 2 jobs overlap and the cost is maximum ?
Q6. Printing a binary tree L-R,
Q7. Implementing a comparator function to sort files based on a certain naming convention.
Q8. Implement a LRU cache?
Q9. Design FB newsfeed?
Q10. How would you query for all the Places near a given coordinate? The focus is on how to scale this to a large number of places while keeping response time to within acceptable user expectations?
Q11. Finding maximum subarray sum (similar to Kadane’s Algorithm) with the constraint that two numbers in the array that form the max sum cannot be next to each other.
Q12. How do you use Facebook app and what are the problems with it? How would you fix it?
Q13. Design a Facebook travel app?
Q14. Designing a system to do spam detection work and describing it in a huge flowchart, as might be done in an early but detailed product planning session. Be prepared to think on large scales.
Q15. Write a palindrome-checking function?