Facebook Interview – Set 1

Company: Facebook
College: Bits Pilani

Facebook visited our campus in July, 2012. We had an online coding round hosted on InterviewStreet. We were asked to solve just one problem. The given problem boils down to : Given a undirected graph, source and destination, write the code to find the total number of distinct nodes visited, considering all possible paths.
Those shortlisted had to fly to Delhi for a Personal Interview. There were four rounds of interview, each of 45 minutes. The questions were simple. But just solving the given problem wasn’t enough.
There was much more interaction and short questions asked related to the problem.

The following questions were asked during the interview.
Q1.  Given two “ids” and a function getFriends(id) to get the list of friends of that person id, write a function that returns the list of mutual friends.
Q2.  Given an “id” and a function getFriends(id) to get the list of friends of that person id, write a function that returns the list of “friends of friends” in the order of decreasing number of mutual friends, as in friend recommendations.
These two questions involved use of STL since I used C++. Questions related to the internal implementation of various STL templates were asked.
Q3.  Given a number of time slots – start time and end time,“a b”, find any specific time with the maximum number of overlapping. After solving the problem I had to prove my solution.
Q4.  Given an array of Integers, find the Longest sub-array whose elements are in Increasing Order.
Q5.  Given an array of Integers, find the length of Longest Increasing Subsequence and print the sequence.
Q6.  Given a Sorted Array which has been rotated, write the code to find a given Integer.
Q7.  You have a number of incoming Integers, all of which cannot be stored into memory. We need to print largest K numbers at the end of input.
Q8. Implement LRU Cache.

For every solution I was asked to write the code on paper. The code should also include the implementation of the data structures used (I used heaps – so I was asked to implement heaps ). They are looking for someone with good problem solving skills and conceptually sound in data structures.

Thanks Prakah V. for contributing this article. If you would like to contribute, mail us your interview experience at [email protected] We will like to publish it on CrazyforCode and help other job seekers.


2 Thoughts on “Facebook Interview – Set 1

  1. Anonymous on October 9, 2013 at 5:41 pm said:

    I have a phone interview with Facebook tomorrow and have been studying problems and algorithms and data structures like crazy. Would you have any advice or recommendations for how to do well or what to focus on for the interview.

    As a side note, that distinct nodes problem seems a little weird. If I understand it right, you can repeat nodes in order to get to the destination. So the number of distinct nodes would just be the number of nodes in the connected component that includes source and destination right. So you just count every node. or is that wrong?

  2. attorney registration and disciplinary commission on April 20, 2014 at 6:53 am said:

    Very good blog you have here but I was wondering if you knew of any discussion boards that cover the same topics discussed in this article?
    I’d really like to be a part of community where I can get suggestions from
    other experienced people that share the same interest.
    If you have any suggestions, please let me know. Cheers!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Post Navigation