My Facebook Interview Experience
blog.casanovawebdesign.com
blog.casanovawebdesign.com
It was a straightforward technical screening but the reason I remember it was because of the verbal emptiness from the interviewer. As I coded for him live on the spot I swear to god he was doing his own work or doing something else. Often I would ask him questions, comment, or walk him through my code and he showed absolutely no interest and often got lost saying things like "hey wait a second, what did you say?" as I heard him typing away at his keyboard, lol.
And did you mean users instead of friends? If a user is already a friend with someone, that means they can only be one degree away.
Here's what I came up with. Is this about right?
# Set up a mock DB holding users and relationships.
# 1 is 1 degree from 2, 5 and 6
# 1 is 2 degrees from 3, 4, 6
# 1 is 3 degrees from 7 and 8
# 1 is 4 degrees from 7 and 8
people_store = [''] #0 -- put blank in 0 so we can have a one-based list.
people_store.append([2,5,6]) #1
people_store.append([1,3]) #2
people_store.append([2,4,6]) #3
people_store.append([3,6,7,8]) #4
people_store.append([1]) #5
people_store.append([1,3,4]) #6
people_store.append([4,8]) #7
people_store.append([4,7,9]) #8
people_store.append([8]) #9
def find_users_within_x_degrees(user_id, degrees):
"""Given a user ID, find other users within two degrees."""
# Users that are within the degree range.
# Start by adding current user's friends (1 degree).
users_within_range = set(people_store[user_id])
# Keep track of user IDs that have been checked.
checked_ids = set()
# Start at 2, because we have already handled 1 degree above.
for degree in range(2, degrees+1):
# Get other users IDs and get their friends. Only do so for users we haven't checked.
for other_user_id in users_within_range.difference(checked_ids):
checked_ids.add(other_user_id)
# Add other user's friends.
users_within_range.update(people_store[other_user_id])
# Because friendships are reciprocal, if the number of degrees is > 1, the requested user_id will be in the set, and should be removed.
if degrees > 1:
users_within_range.remove(user_id)
return users_within_rangeI will definitely look into your suggestion, because if it's the optimal solution, I want it to be the first one I think of. Even though these types of problems don't come up for me that often, I'm sure there are times where a textbook CS solution would have been the best solution.
This obsession with puzzles is frustrating.
For all I know on some of the puzzle-type questions I got a slightly wrong or sub-optimal answer... but I never have any idea if that's what sunk me, or if the interviewer didn't like me personally, or if my whiteboard handwriting was too bad to read, etc.
Very frustrating experience, these type of things. Though working on the puzzles is always fun (and sometimes, I kick myself afterward for missing something that seems obvious in retrospect)
If you're applying for a job at a puzzle-solving factory, fine. But if you want people who really know how to solve problems, this kind of question usually doesn't get you those kinds of people.
The team I interviewed for was less technical than a core engineering team but the process was much more straightforward and actually easier than I expected. I'm from outside the US and had heard about month long hiring processes and day long interviews but in reality it was three short phone interviews and a single in-person interview which they paid for. I got the feeling they were looking for a personality fit rather than just engineering skills.
The questions asked by the Palo Alto team in rounds 1-5 were some of the toughest real-world questions I've had for an infrastructure programming role.
The London team (in on on-site for rounds 6-9) were more concerned about whether I had a degree, that I used Linux at home rather than a Mac, and whether I could code PHP (which hadn't been mentioned before).
FWIW, it seems like a good problem to me. Dynamic programming is essential to finding good algorithmic solutions to many fundamental CS problems so I would expect everyone to be able to use it.
Edit: Thanks to kenjackson for correcting my numbering. The second problem doesn't look like it requires dyn prog to me.
At least they're not asking why man hole covers are round, or if you had a bathtub the size of New York how many Grand Pianos would fit in it (correct answer: "I'm not aware that the Grand Piano is an internationally recognised standard unit of measure")
On the other hand, interviewing is not a solved problem in IT. It can't be, otherwise half (or more) of the people would never have gotten in, and productivity would soar.
On the gripping hand, for all that I want to denigrate Facebook, these questions do actually make sense - do you want people on your server writing an O(n) algorithm when an O(log n) one will do? When N is ridiculously large, like 500 million or something like that? And if the only place to learn these things is in an academic environment, then so be it. I admire the generic self-taught programmer as much as anybody else, but if they really love what they do, it would behoove them to borrow someone's old computer science textbooks and skim through them.
I would much prefer to see a sample of data they work with anonymized and being asked to come up with a creative solution to a specific problem.
It looks like they are for graduates/junior positions when there are not so many other things to talk about.