## Facebook Interview Questions

- 0of 0 votes
Given a list of Contacts, where each contact consists of a contact ID and a list of email IDs. Output a unique list of contacts by removing duplicates. Two contacts are considered to be the same, if they share at least one email ID.

- 0of 0 votes
Given an integer, print an English phrase that describes the integer (eg, "Two hundred and thirty four", “One Thousand, Two Hundred and Thirty Four”)

- 0of 0 votes
You are given n points (x1, y1), (x2, y2), ..... (xm, ym) of a two dimensional graph. Find 'n' closest points to (0,0) [ n <= m ]. Euclidean distance can be used to find the distance between 2 points.

- 0of 0 votes
write a class that 1) calculates the average of the stream, 2) provides an API read the average.

Handle overflows as the numbers can be very large and not fit into double/long.

- -2of 2 votes
Given an array of lower case strings, the task is to find the number of strings that are special equivalent.

Two strings are special equivalent if they can be made equivalent by performing some operations on one or both string

swapEven : swap a character at an even-numbered index with a character at another even-numbered index

swapOdd : swap a character at an odd-numbered index with a character at another odd-numbered index

Input : arr = {"abcd", "cbad", "bacd"}

Output : 2

The 2nd string can be converted to the 1st by swapping

the first and third characters. So there are 2 distinct

strings as the third string cannot be converted to the

first.

string input[] = {"abcd", "acbd", "adcb", "cdba",

"bcda", "badc"};

ans =4

- 6of 6 votes
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.

- 2of 2 votes
Given 2 strings representing very large numbers (these are not representable as a BigInteger or other various type) write a method for adding the two numbers and returning their sum.

- -2of 2 votes
word look up

- 2of 2 votes
I was asked to design a system on a whiteboard which simulate a executor.

This system has a method that is being triggered every second. I need to add logic to the method (i.e. run jobs).

There is also a method called job_arrived() that is called when a new job arrives.. I need to implement it as well.

I needed to implement a system which tries to run each job right when it is arrived (it has a return value that gets a success status from a black box service). if the job ran successfully that's the end of it..

if not I need to re-run it after 2 seconds (and if that fails as well - there will be no re-runs).

of course - more than one job can be accepted each second.

I was asked to describes the system (describe the classes and method) and consider the system to be large scale one (meaning.. threading is in order here..).

The answer I gave was apparently not multi threaded enough..

any idea to what I should have done?

Thanks guys

- 5of 5 votes
Congrats on aonecode member A.P. for signing the offer with FB! Thanks for sharing the experience with us.

phone:

postorder tree traversal recursive -> iterative

add two binary number

on-site:

1 ring buffer

2 merge intervals

3 Leetcode alien dictionary

4.sort list of words

- 1of 1 vote
Given a number, rearrange the digits of that number to make a higher number, among all such permutations that are greater,one of them is the smallest, Find the smallest greater permutation (the next Permutation).

Examples:

next_permutation (12) = 21

next_permutation (315) = 351

next_permutation (583) = 835

next_permutation (12389) = 12398

next_permutation (34722641) = 34724126

- -2of 2 votes
If b == “1”:

quit()

- 0of 0 votes
Given a binary tree, where each node represents an integer, find the max value of path sum.

- 5of 5 votes
FB On-site March

Q: Find number of Islands.

XXXOO

OOOXX

XXOOX

Return 3 islands.

1 1 1OO

OOO2 2

3 3OO 2

Followup: If the board is too big to fit in memory, how to get the number?

- 1of 1 vote
Interleave list of lists in Java

Example:

input = [[1,2,3], [9, 0], [5], [-4,-5,-2,-3,-1]];

output = [1,9,5,-4,2,0,-5,3,-2,-3,-1]

- 0of 0 votes
Given an array of n elements return true if 3 of the sum of 3 elements is equal to a constant c

Example array a[6,2,3,4] constant c = 9

if a[1] + [2] + [3] == c return true

The size of the array is n

If any set of 3 elements is equal to the constant c, then return false

- 2of 2 votes
Given a string with alpha-numeric characters and parentheses, return a string with balanced parentheses by removing the fewest characters possible. You cannot add anything to the string.

- 2of 2 votes
Given a collection of two dimensional points and a number k, return the k closest points to (0,0) by Euclidean distance.

- -2of 2 votes
How do I report a problem with Facebook?Facebook Advertising Help, Tips & Support | Facebook for Business provide facebook help center number ?

- 1of 1 vote
Given a string as input, return the list of all the patterns possible:

`'1' : ['A', 'B', 'C'], '2' : ['D', 'E'], '12' : ['X'] '3' : ['P', 'Q']`

Example if input is '123', then output should be [ADP, ADQ, AEP, AEQ, BDP, BDQ, BEP, BEQ, CDP, CDQ, CEP, CEQ, XP, XQ]

- 1of 1 vote
Move[inplace] the non zero elements at the one end(end of array) and return the numbers of non zero elements in output array

Solution : https://www.geeksforgeeks.org/move-zeroes-end-array/

- -1of 1 vote
what is UI/Main Thread in android.

when you can use Thread over Service

- -1of 1 vote
Question 2: Given a number 'k', return the corresponding row, given the pattern:

k => output

0 => []

1 => ["0", "1", "8"]

2 => ["00", "11", "69", "96", "88"]

3 => ["000", "111", "101", "888", ...] // and so on ...

- 0of 0 votes
Question 1: Given an input of an array of string, verify if, turned 180 degrees, it is the "same".

For instance:

[1, 6, 0, 9, 1] => return true

[1, 7, 1] => return false

- 2of 2 votes
March 2018 Phone Interview FB

Calculate a moving average that considers the last N values.

Circular Queue (Interviewer didn't agree with the linked list queue that I suggested at first. Said the pointers took space)

- 0of 0 votes
Why facebook?

What was the biggest technical problem that you solved?

Do you have any apps on google play?

Give me a scenario where the requirements were ambiguous, what did you do?

- 0of 0 votes
Design Instagram like app end to end

- 0of 0 votes
Given a string "L*&EVe)))l", write a method which will determine if the input is a palindrome. Ignore all special characters. Uppercase/lowercase should be considered as same.

- 0of 0 votes
Imagine a room full of people, with only 1 celebrity in the room. Celebrity is defined as a person who does not know anyone, but everyone knows him/her. Write a method who will take array of people and a person as input and return boolean if the person is a celebrity or not.

- 0of 0 votes
Given two input arrays, return true if the words array is sorted according to the ordering array

Input:

words = ['cc', 'cb', 'bb', 'ac']

ordering = ['c', 'b', 'a']

Output: True

Input:

words = ['cc', 'cb', 'bb', 'ac']

ordering = ['b', 'c', 'a']

Output: False