Facebook Onsite Interview Preparation Part 2: Coding Questions


The Facebook Onsite Interview will generally consist of three parts: Motivations, and Part 2 Coding, and Part 3 Product Design. This is the Part Two: Coding.

At least 2x 45mins interviews where you need to know your data structures and algo’s, it’s similar to the phone interview. In general, you need to translate your thoughts to code and work around any constraints.

In general, here are the advices:

  • You should: PRACTISE PRACTISE PRACTISE!
  • Use the Careercup and codelab links provided below for example questions.
  • Put yourself under time constraints, speed is important in the interview.

Remember:

  • We can only evaluate you on the code you write.
  • To talk about what you are doing throughout the interview. If you need to be quiet to think, that’s great – just let the interviewer know.

7 steps to success in your Facebook coding interview

  • Do not jump straight into coding, take a few mins to understand the problem and ask any clarifying questions (but not too long!).
  • Describe your solution to your interviewer and get their thoughts on your solution.
  • Think about your algorithm(s) including the complexity and runtime. Ask the interviewer if it’s ok or if you should think about something more optimized.
  • Then figure out your data structure and implement.
  • Run through your code verbally with your interviewer. This is really important at this point. Does it really do what you think it does? Make sure to read what is there, not what you think is there.
  • Test your code, put in an input to see what happens. FB is looking for you to find the bugs yourself and fix anything that comes up
  • Restate the complexity. Is it the same, or different to your initial thinking based on what you have actually coded up? Make sure you’re thinking about both space and time
  • Optimize. Proactively suggest ways to optimize to the interviewer and get their feedback to ensure what you’re trying to do is not overly complex and is correct then code it up.

One important tip to hack your interview, you should practice questions on careercup/leetcode on a whiteboard before you come in, or on A3 paper. Please refer back to your initial interview prep to get ready for the coding interviews.

There will be questions like:

  • Write the code to print the first element of each “row” of a binary tree. (want to see that you know how to convert a list to multi-dimensional array)
  • Implement a tic-tac-toe game.
  • Write the code to show the number and type of permutations of a given string

Think out loud if you are working through a solution you are presented with as the Engineer will want to know how you approach and troubleshoot problems. If the interviewer gives you hints to improve your code, take them and run with them. It is good to adjust and work through the problems with the interviewer to show your thought process and problem-solving ability.

Other things to consider include knowing the complexity of the algorithm you are writing, its running time and whether your solution could be improved or optimized. You should also check for edge cases and be thinking about how you might test your code to prove it works. Specifics to consider:

  • Your interviewer will be evaluating your code on efficiency, bugs, and timeliness.
  • Take hints from your interviewer to showcase your thought process and problem-solving ability.
  • Generally avoid solutions with lots of edge cases or huge if/else if/else blocks. Deciding between iteration and recursion is always an important step.
  • Think about different algorithms and algorithmic techniques (sorting, divide-and-conquer, dynamic programming/memorization, recursion).
  • Think about data structures, particularly the ones used most often (Array, Stack/Queue, Hashset/Hashmap/Hashtable/Dictionary, Tree/Binary Tree, Heap, Graph, Bloom Filter, etc.)
  • Don’t worry about rote memorization such as runtimes or API/native calls. It’s good to know how to figure out approximate runtimes on the fly but the code you write is more important.
  • You will be asked about O(Memory) constraints, the complexity of the algorithm you are writing and its runtime – O(N^2), O(N) etc
  • Make sure you review recursion.
  • Make sure you know what your base case is. Bonus points available for talking about or implementing the dynamic programming solution.

What Facebook is looking for in a nutshell: Basic coding hygiene, Can you whiteboard some code, test it and talk about its running time!

facebook-hacker Facebook Onsite Interview Preparation Part 2: Coding Questions facebook interview questions interviews

facebook-hacker

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
943 words
Last Post: The Process Killing Algorithms using Depth First Search or Breadth First Search (Kill a Process)
Next Post: The Facebook Initial Coding Interview Experience

The Permanent URL is: Facebook Onsite Interview Preparation Part 2: Coding Questions

Leave a Reply