Facebook Interview Questions
- 1of 1 vote
AnswersFind the in-order successor of a node in BST
- Kiara July 20, 2015 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer - 4of 4 votes
AnswersDesign a data structure that supports kind of full text search but in numbers.
- coredo July 14, 2015 in United States
We are given file with lot of 10-digits numbers, for example:
1234 567 890
4124 123 123
3123 123 322
On a given number X we should return all numbers that contain X.
For example, if the number 123 was given, we should return all numbers (from the list above) because 123 is in all of them.
If the number 41 was given we should return only the middle number - because the number 41 is only in it.| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Data Structures - 2of 2 votes
AnswersDesign Facebook Messenger backend
- tested.candidate July 13, 2015 in UK| Report Duplicate | Flag | PURGE
Facebook Software Engineer System Design - 0of 0 votes
AnswersGiven an array of contacts with phone numbers/emails you should detect and union identical contacts.
- coredo July 12, 2015 in United States
For example, given the following contacts array:
[ [ "John", "john@gmail.com", "john@fb.com"],
[ "Dan", "dan@gmail.com", "+1234567"],
[ "john123", "+5412312", "john123@skype.com"],
[ "john1985", "+5412312", "john@fb.com"] ]
We can see that john1985, John and john123 are the same person by their contact information.
We should output
[[ 0, 2, 3], [1]] (0,2,3 are the same person and 1 is another one)| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm - 0of 0 votes
AnswersSearch in a sorted rotated array.
- Kiara May 21, 2015 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer - 0of 0 votes
AnswersMerge K sorted singly linked list
- Kiara May 21, 2015 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer - 0of 0 votes
Answerspaint a list of N houses and M colors, each combination has cost, minimize the total cost without color in row.
- Kiara May 21, 2015 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer - 1of 1 vote
AnswersGiven array A of size N, using function Random(returns random number between 0 and 1) implement function that will return array of size N with randomly shuffled elements of the array A.
- RambamSM May 07, 2015 in India
You shoul give only algo.| Report Duplicate | Flag | PURGE
Facebook - 1of 3 votes
AnswersWe know a string is Palindrome if it is the same reading from both sides. Now we define the following string also Palindrome:
- amirtar May 05, 2015 in United States
A man, a plan, a canal, Panama!
Write a code that returns if an string is palindrome and it should return true for above input. (Without directly saying, I should conclude that I have to only consider alphanumerical characters in a string). In addition, we assume the string is very long and we can not keep a copy of this string or even a copy of preprocessed version of this string. Therefore the result should be returned with the first sweep of the string.| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm String Manipulation - 0of 0 votes
AnswersGiven a singly linked list, swap the list items in pairs (reconnect the pointers, not simply swap the values). For example:
- Kiara April 22, 2015 in United States
Before: A->B->C->D
After: B->A->D->C| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer - 1of 1 vote
Answersyou have a interface called Op and a Filter interface
- HBY April 17, 2015 in United States
interface Op<T> {
public boolean hasNext();
public boolean<T> next();
}
interface Filter<T1, T2> {
public boolean filter(T1 t1, T2 t2);
}
design a MutualOp that has below API, MutualOp should return the ops that combine op1 and op2, also should meet with the filter
class MutualOp implements Op{
public MutualOp(Op left, Op right, Filter<Op, Op> filter) {
this.left = left;
this.right = right;
this.filter = filter;
}
public boolean hasNext {
......
}
public T next {
......
}
}| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 0of 0 votes
Answerscalculate minimum h-index for a sorted integer array(http://en.wikipedia.org/wiki/H-index)
- HBY April 17, 2015 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 1of 1 vote
AnswersAssuming you're playing one game that you need guess a word from a dictionary. You're given a machine you can try to guess the word, the machine will return how many characters has been matched by your guess. Design a system to crack the word.
- HBY April 17, 2015 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 1of 1 vote
AnswersPermutate a list of string
- HBY April 17, 2015 in United States
this question is supposed permutate the characters instead of who string,
as input example {"red", "fox", "super" }, the expected output is
rfs
rfu
rfp
rfe
rfr
ros
rou
rop
roe
ror
rxs
rxu
rxp
rxe
rxr
efs
efu
efp
efe
efr
eos
eou
eop
eoe
eor
exs
exu
exp
exe
exr
dfs
dfu
dfp
dfe
dfr
dos
dou
dop
doe
dor
dxs
dxu
dxp
dxe
dxr| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 1of 1 vote
AnswersA 2D array filled with integer, define a flow from one point to its neighbor only if the value of current point is not less than its neighbor's value. Consider up edge and left edge as east coast, bottom edge and right edge as west coast, find all position that it can flow to east coast and west cost both
- HBY April 17, 2015 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - -5of 7 votes
AnswersSort an integer array with three functions: findMin(), findMedium(), findMax().
- VV April 17, 2015 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer Intern Sorting - -1of 1 vote
Answers/**
- dingdong April 16, 2015 in United States
* Find if the given list of recurring weekly intervals covers the
* entire time. Times are given up to a second.
*
* You can take the input intervals in the number of seconds since
* the beginning the week or any other format you prefer.
*
* ---Example 1---
* Input:
* Tuesday 9AM - Sunday 9AM
* Sunday 8:00:20AM - Wednesday 3AM
*
* Output:
* true
*
* ---Example 2---
* Input:
* Tuesday 9AM - Sunday 9AM
* Sunday 8:00:20PM - Tuesday 8AM
*
* Output:
* false
*/| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 3of 3 votes
Answers/*
- dingdong April 16, 2015 in United States
For each node in a binary tree find the next right node on the same depth. Write a function that takes root node and populates "next" with the answer for each node.
A
/ \
B -> C
/ / \
D -> F-> G
/ \
H -> I
class Node {
Node left;
Node right;
Node next; // <-- answer should be stored here
};
B.next = C
D.next = F
F.next = G
H.next = I
{A, C, G, I}.next = null
*/| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - -4of 4 votes
AnswersPangram
- Kiara April 16, 2015 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer - 0of 2 votes
AnswersIn-place Palindrome Check
- Kiara April 16, 2015 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer - -5of 7 votes
Answersdutch national flag w/ get rank followup
- Kiara April 16, 2015 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer - 0of 0 votes
Answersgiven an array (list) of integers return true(boolean function) if two of the numbers add to 12.
- nitz April 15, 2015 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer Intern Java - 3of 3 votes
AnswersN queen problem.
- animageofmine April 08, 2015 in United States
In NXN chess board, you have to arrange N queens such that they do not interfere each other. Following is how you define interference of queens.
1. Two queens cannot be on the same diagonal
2. Two queens cannot be in same horizontal or vertical line
3. Queen can jump like a knight. So, two queens cannot be at a position where they can jump two and half steps like a knight and reach the other queen.
You should return the possible ways to arrange N queens on a chess board.
This was a tech screen, but since I was local, they called me in their office rather than phone interview.
Hint: Don't try too hard, the best solution is n!| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 0of 2 votes
AnswersI needed to develop next system:
- Stanand April 05, 2015 in United States
We have a lot of servers. Every server generate logs. Every log has two data types: first is numeric metrics. These numeric metrics are integer. Second is strings. We need to collect logs from all servers on other server (storage). Then we have to execute queries and get some data from storage. In our queries we have to use numeric metrics and strings as well. For numerics metrics we have to be able get aggregation data as well.
Develop Storage server, database. Describe how will you scale this system, what database will you use, how will you save data and how will you execute this queries.| Report Duplicate | Flag | PURGE
Facebook Developer Program Engineer Distributed Computing - 6of 6 votes
AnswersGiven an array such that every next element differs from the previous by +/- 1. (i.e. a[i+1] = a[i] +/-1 ) Find the local max OR min in O(1) time. The interviewer mentioned one more condition that the min or max should be non-edge elements of the array
- xyz March 30, 2015 in United States
Example: 1 2 3 4 5 4 3 2 1 -> Local max is 5
1 2 3 4 5 -> No local max or min exists
5 4 3 2 1 -> No local max or min exists| Report Duplicate | Flag | PURGE
Facebook Software Developer Algorithm - 0of 2 votes
Answerswrite a function that calculates the minimum number of meeting rooms that can accommodate given schedules
- bazinga March 24, 2015 in United States
input: same
output: # of rooms
Also back to back events are allowed e.g. {2,5} {5,9} correct o/p:1| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 2of 2 votes
Answerswrite a function that detects conflicts in given meeting schedules
- bazinga March 24, 2015 in United States
input: a list of intervals, [(s1, e1), (s2, e2), ]
output: return True if there's any conflict, False otherwise| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - -1of 1 vote
AnswersGiven a tokenized PHP file, give me a map from class to list of functions
- Kiara March 19, 2015 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer - 0of 0 votes
AnswersThere are 3 romms in which party is going on lets say room A, B, C. Guests are coming one by one and you have to tell the guest
- swastikSoft March 14, 2015 in United States
which room to enter. At any point of time each room has to maintain a percentage Lets say the percentage that each room has to maintain is
A- 20% , B-30% , C- 50%. You can maintain total count of each room and keep on adding count to respective room as the new guest enters each room.
How would you go about it. What formula would you use.
Give a generalise formula so that it works if no. of rooms increase.| Report Duplicate | Flag | PURGE
Facebook Software Developer Algorithm - 6of 6 votes
AnswersYou are given a 2d rectangular array of positive integers representing the height map of a continent. The "Pacific ocean" touches the left and top edges of the array and the "Atlantic ocean" touches the right and bottom edges.
- JD March 14, 2015 in United States
- Find the "continental divide". That is, the list of grid points where water can flow either to the Pacific or the Atlantic.
Water can only flow from a cell to another one with height equal or lower.
Example:
Pacific ~ ~ ~ ~ ~ |__
~ 1 2 2 3 (5) ~
~ 3 2 3 (4)(4) ~
~ 2 4 (5) 3 1 ~
~ (6)(7) 1 4 5 ~
__ (5) 1 1 2 4 ~
|~ ~ ~ ~ ~ Atlantic
The answer would be the list containing the coordinates of all circled cells:
[(4,0), (3,1), (4,1), (2,2), (0,3), (1,3), (0,4)]| Report Duplicate | Flag | PURGE
Facebook Algorithm