Facebook Interview Questions
- 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 - -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 - 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
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 - 3of 3 votes
AnswersImplement stairs(N) that (collect the solutions in a list) prints all the ways to climb up a N-step-stairs
- pk March 14, 2015 in United States
where one can either take a single step or double step.
We'll use 1 to represent a single step, and 2 to represent a double step.
stairs(3)
111
12
21| Report Duplicate | Flag | PURGE
Facebook Software Engineer - 3of 5 votes
AnswersA robot has to move in a grid which is in the form of a matrix. It can go to
- thisandthat March 09, 2015 in United States
1.) A(i,j)--> A(i+j,j) (Down)
2.) A(i,j)--> A(i,i+j) (Right)
Given it starts at (1,1) and it has to go to A(m,n), find the minimum number of STEPS it has to take to get to (m,n) and write
public static int minSteps(int m,int n)
For instance to go from (1,1) to m=3 and n=2 it has to take (1, 1) -> (1, 2) -> (3, 2) i.e. 2 steps| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 3of 3 votes
AnswersQuestion: Given a sequence of positive integers A and an integer T, return whether there is a continuous sequence of A that sums up to exactly T
- ep February 27, 2015
Example
[23, 5, 4, 7, 2, 11], 20. Return True because 7 + 2 + 11 = 20
[1, 3, 5, 23, 2], 8. Return True because 3 + 5 = 8
[1, 3, 5, 23, 2], 7 Return False because no sequence in this array adds up to 7| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 2of 2 votes
AnswersInput: A string equation that contains numbers, '+' and '*'
- huji February 23, 2015 in Israel
Output: Result as int.
For example:
Input: 3*5+8 (as String)
Output: 23 (as int)| Report Duplicate | Flag | PURGE
Facebook Software Engineer - 1of 1 vote
AnswersGiven a class Range
class Range { public int begin; public int end; public Range(int begin, int end) { this.begin = begin; this.end = end; } }
The problem:
- huji February 23, 2015 in Israel
Intput:
1) list of Ranges that don't overlap (not sorted)
2) newRange that might overlap.
Output:
list of merged Ranges
For example:
Input: [1..5] [9..13] [17..22]
newRange: [4..10]
Output: [1..13] [17..22]| Report Duplicate | Flag | PURGE
Facebook Software Engineer - 1of 1 vote
AnswersConvert a binary tree into a In Order traversal circular list re-purposing the node's pointers Left & Right as Previous and Next respectively.
- Nelson Perez February 22, 2015 in United States
Hint: A single node Left & Right points to itself.
Note: This is not a binary search tree.| Report Duplicate | Flag | PURGE
Facebook Software Engineer Coding - 0of 0 votes
AnswersCompletely blew it on this question today.
- jsdude January 28, 2015 in United States
1.) Given an array, find the maximum difference between two array elements given the second element comes after the first.
For example.
array = [1,2,3,4,5,6,7]
We can take the difference between 2 and 1 (2-1), but not the different between 1 and 2 (1-2).
This question is super easy, I solved it within minutes of getting of the phone. I came up with an O(n^2) solution over the phone. My improved solution was O(n).| Report Duplicate | Flag | PURGE
Facebook Software Engineer Arrays