Leave your Email to get the latest Meta interview questions weekly.

We'll never share your email with anyone else.

No spam we promise.

Search Matrix

Given a 0-1 matrix, where 1 means block, 0 means road, return the number of paths from row one to row bottom...

Design Ads Click Counter System

Think about ads platform like Google/Meta. There are billions of ads clicks per day. Now we need to design a dashboard to visualize the ads performance. More specifically, you need to implement a service to return the number of ads clicks within a certain time frame...

File Checker

Given an API reads 1 char at a time from a file, check if two files are identical...

Max Submatrix Sum

Given a matrix and an integer k, return the maximum sum of all the k x k matrices

Can Make Palindrome

Given a list of lowercase letters, find whether the letters can make a palindromic string...

Measure Island Border

Given a binary matrix where 1 denotes land and 0 denotes water, return the number of border tiles...

Maximum Difference Between Ancestor and Descendant

Given a binary tree, find the max difference between an ancestor and its descendant...

Canonical Path

Given the absolution path to a folder in Unix, convert it to the canonical path...

Bejeweled Scores

A 10 x 10 board is filled with randomly placed gems. A match occurs when 3 or more gems of the same color line up in a row either horizontally or vertically...

Add Bold Tags To String

Given a string S and a list of key terms, return a string with the key terms surrounded by tags...

Subtree Average

Given a binary tree, find out every tree node where its value equal to the average of all nodes in this subtree...

Longest Monotonic Path in Tree II

Find out the length of longest monotonic path starting from any node to its descendent node in a binary search tree...

Longest Monotonic Path in Tree I

Find out the length of longest monotonic path starting from the root node of a binary search tree...

Count Number in Sorted Array

Given a sorted array of integers and a target number, return the count of the target number...

Minimum Time to Complete Tasks

Given a project with a list of tasks, find out the minimum amount of time to complete the project...

Longest Monotonic Path in Tree III

Find out the length of longest monotonic path starting from any node to its descendent node in a binary tree...

Intersection Two Lists of Intervals

Given two lists of intervals, each interval denoted as [start, end], find the intersection (overlapped segments) between the lists...

Min Steps To Remove Increasing Sequence

Given an array of numbers, remove the increasing sequences until there is no change.

...

Sort String By Custom Alphabetical Order

[Facebook Onsite Question] Sort String By Custom Alphabetical Order

Task Scheduler II

[Facebook Onsite Question] Task Scheduler II

Given an array of numbers [1, 2, 3, 1, 4, 2, ..... ]. (Notice there could be duplicate) Also given an integer N, which means two same numbers must be N space away.

You are going to write a program to find out a way to padding zeros to these numbers with the minimum total length...

Merge Segments

# There's a room with a TV and people are coming in and out to watch it. The TV is on only when there's at least a person in the room.

# For each person that comes in, we record the start and end time. We want to know for how long the TV has been on. In other words:

# Given a list of arrays of time intervals, write a function that calculates the total amount of time covered by the intervals.

# For example:

# input = [(1,4), (2,3)]

# > 3

# input = [(4,6), (1,2)]

# > 3

# input = {{1,4}, {6,8}, {2,4}, {7,9}, {10, 15}}

# > 11

Set Matrix Zeroes II

Google On-site 2018 Winter

There are orbs on an NxM board ('O' denotes orb. 'X' denotes empty slot).

Whenever two orbs are in the same column or the same row, you get to erase one of them.

Try to erase as many orbs as possible.

Find the minimum number of orbs remained on board eventually.

Randomly select a number in an array

How to randomly select a number in an array?

array: [15, 2, 4, 5, 1, -2, 0]

Follow-up:

Given a second array freq where freq[i] represents the occurrence of the ith number in array, how to randomly select a number in array based on the frequency.

Extra requirement:

Could you complete the selection in a single-pass(go through each array only once)?

Ring Buffer

Implement a ring buffer

Cut Binary Tree

Give a binary tree, find if it's possible to cut the tree into two halves of equal sum. You can only cut one edge.

Split BST

Given a Binary Search Tree (BST) with root node root, and a target value V, split the tree into two subtrees where one subtree has nodes that are all smaller or equal to the target value, while the other subtree has all nodes that are greater than the target value. It's not necessarily the case that the tree contains a node with value V.

Longest Arithmetic Progression

In the array {1, 6, 3, 5, 9, 7}, the longest arithmetic sequence is 1, 3, 5, and 7