Most common Facebook coding Interview questions

The 15 Most Asked Questions in a Facebook Coding Interview

With more than 85 offices worldwide, Facebook (called Meta now) has been a dream workplace for all software developers and engineers. But with the competition being so tough, not everyone does well with Facebook interview questions.

Getting through multiple rounds of Facebook interview questions is only possible with the right guidance. That’s why our experts have created a coding interview guide to help you pass the Facebook interview. Our experts have been working with FAANG companies, and after thorough research and experience, we’ve filtered the top practice questions to help you excel in your Facebook coding interview.

Arrays

Move zeros to the left

Problem Statement

Given an integer array, move all elements that are equal to 0 to the left while maintaining the order of other elements in the array.

Merge overlapping intervals

Problem Statement

Given a list of intervals, merge all the overlapping intervals to produce a list that has only mutually exclusive intervals.

Linked Lists

Add two integers

Problem Statement

Given the head pointers of two linked lists where each linked list represents an integer number (each node is a digit), add them and return the resulting linked list.

Merge two sorted linked lists

Problem Statement

Given two sorted linked lists, merge them so that the resulting linked list is also sorted.

Trees

Convert binary tree to doubly linked list

Problem Statement

Convert a binary tree to a doubly linked list so that the order of the doubly linked list is the same as an in-order traversal of the binary tree. After conversion, the left pointer of the node should be pointing to the previous node in the doubly linked list, and the right pointer should be pointing to the next node in the doubly linked list.

Level order traversal of binary tree

Problem Statement

Given a binary tree and a number ‘S’, find all paths from root-to-leaf such that the sum of all the node values of each path equals ‘S’.

Strings

Reverse words in a sentence

Problem Statement

Reverse the order of words in a given sentence (an array of characters).

String segmentation

Problem Statement

Given a dictionary of words and an input string tell whether the input string can be completely segmented into dictionary words.

Dynamic Programming

Find maximum single sell profit

Problem Statement

Given a list of daily stock prices (integers for simplicity), return the buy and sell prices for making the maximum profit. We need to maximize the single buy/sell profit. If we can't make any profit, we'll try to minimize the loss.

Math and Stats

Calculate the power of a number

Problem Statement

Given a double, 'x', and an integer, 'n', write a function to calculate 'x' raised to the power 'n'.

Backtracking

Find all possible subsets

Problem Statement

You are given a set of integers and you have to find all the possible subsets of this set of integers.

Graphs

Clone a directed graph

Problem Statement

There is a dictionary containing words from an alien language for which we don’t know the ordering of the characters. Write a method to find the correct order of characters in the alien language.

Design

Serialize / deserialize binary tree

Problem Statement

Serialize a binary tree to a file and then deserialize it back to a tree so that the original and the deserialized trees are identical.

Sorting and Searching

Find the high and low index

Problem Statement

Given a sorted array of integers, return the low and high index of the given key. Return -1 if not found. The array length can be in the millions with many duplicates.

Search rotated array

Problem Statement

Search for a given number in a sorted array that has been rotated by some arbitrary number.