Facebook Interview Questions
- 1of 1 vote
AnswersArray has N integers,range[0...N-1]。Set S[k], 0 <= K < N as S[K] = {A[K], A[A[K]], A[A[A[K]]],....},
- ajay.raj July 29, 2017 in United States
write a function returns the size of the largest set S[K] for this array. return 0 if empty.
ex:
A = [5, 4, 0, 3, 1, 6, 2]
return 4 because S[2] equals {0, 5, 6, 2} 4 elements| Report Duplicate | Flag | PURGE
Facebook SDE1 - 0of 0 votes
AnswersGiven an array of integers and a target number, determine if an arithmetic expression using these integers can be evaluated to the target number, you are allowed to use '+', '-', '*', '/'. Follow-up: when evaluating the expression, take operand precedence into account,
- ajay.raj July 27, 2017 in United States
public boolean getTarget(int[] nums, int target){
}
exponentia is ok| Report Duplicate | Flag | PURGE
Facebook SDE1 - 3of 3 votes
AnswersGiven a list of input tasks to run, and the cooldown interval, output the minimum number of time slots required to run them.
- nzt July 26, 2017 in United States
// Tasks: 1, 1, 2, 1, 2
// Recovery interval (cooldown): 2
// Output: 8 (order is 1 _ _ 1 2 _ 1 2 )
=========
Tasks are task numbers in that order coming in for execution. Cooling time is time interval required to cool down the machine after executing a task. So it's like if CPU executed task 1 then it needs 2 cooling time intervals before executing another task 1 but meanwhile, it can execute other tasks which are not same as 1 and so on. So before executing any task, you have to check if you have executed same task number before and if yes, then if its cooling time interval is done or not.
The output is basically the number of cycles/time slots CPU took to execute these tasks in that order (including when task executed and cooling intervals).| Report Duplicate | Flag | PURGE
Facebook Software Engineer - 0of 0 votes
Answersfind the Closest leaf to a given node in Binary Tree
- ajay.raj July 26, 2017 in United States
can you do it in o(n) time
public TreeNode findCloestLeafNode(TreeNode root, TreeNode target){}
no parent pointer| Report Duplicate | Flag | PURGE
Facebook SDE1 - 0of 0 votes
Answervalidate IP in string format and return the uint32 format
- ajay.raj July 26, 2017 in United States
‘1.2.3.4’ -> 0x01020304| Report Duplicate | Flag | PURGE
Facebook SDE1 - 0of 0 votes
AnswersWrite the code to find the median of an unsorted array in average linear time.
- ajay.raj July 21, 2017 in United States
followup the array is distributed across many machines.| Report Duplicate | Flag | PURGE
Facebook SDE1 - 0of 0 votes
AnswerWrite a function to split a SQL query into individual statements.
- ajay.raj July 21, 2017 in United States
give you a String which contains a separate Query with a semicolon ";" return all valid queries
Such as
"select name from courseinfo ;; select * from db1 where home = 'usa' ;"
The main thing to consider is that some special cases such as the escape symbol and the quotation marks inside the semicolon
public List<String> getQuery(String queries){
}| Report Duplicate | Flag | PURGE
Facebook SDE1 - 0of 0 votes
Answersgiven a list of numbers, put with + - * / any two number, find the maximum value you can get.
- ajay.raj July 16, 2017 in United States
int getMaxNumber(int[] nums){
}| Report Duplicate | Flag | PURGE
Facebook Software Engineer - 0of 0 votes
AnswersGiven a group of movies and their start time, assuming that are 1 hour long,
- ajay.raj July 15, 2017 in United States
Returns a movie schedule (no time conflict).
enter:
Movie ("Shining", [14, 15, 16])
Movie ("kill bill", [14, 15])
Movie ("Pulp fiction", [14, 15])
One possible result is shining 16, kill bill 15, pulp fiction 14
public void schedule (HashMap <String, List <Integer >> map) {
}| Report Duplicate | Flag | PURGE
Facebook SDE1 - 3of 3 votes
Answers3.1 design: design fb inbox search —> just focus on the post
- aonecoding July 15, 2017 in United States
4.1 binary tree to circular double linked list.
4.2 two arrays, find the common elements of two sorted array. if one array is small, the other is very big.| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 2of 2 votes
Answers2.1 career discussion
- aonecoding July 15, 2017 in United States
2.2 divide two numbers with no / or %| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 4of 4 votes
Answers1/4 round of FB on-site interview, Master Degree, Hired
- aonecoding July 15, 2017 in United States
1.1 diameter of tree
1.2 find the point which have the maximum overlap of intervals| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 0of 0 votes
Answersfriend circle. Given a streaming pairs representing friend relationship
- ajay.raj July 15, 2017 in United States
(1, 2) means 1 and 2 are friends, (1, 3) means 1 and 3 are friends
Return all its friends.
List<Integer> getFriends (Iterator<List<Integer>> relations, int id){
}| Report Duplicate | Flag | PURGE
Facebook SDE1 - 0of 0 votes
AnswersFor given list of numbers find out triplets with sum 0
- rsa July 14, 2017 in United States
Input : arr[] = {0, -1, 2, -3, 1}
Output : 0 -1 1
2 -3 1| Report Duplicate | Flag | PURGE
Facebook Java - 1of 1 vote
AnswersGiven a String and dictionary of words, break the string in minimum space sentence.
- rsa July 14, 2017 in United States
Ex:
inputStr = "ilikefacebook"
dictionary = {"i","like","face","book","facebook"}
Possible Strings:
i like face book - 3 spaces
i like Facebook - 2 spaces - this is expected answer.| Report Duplicate | Flag | PURGE
Facebook Java - 0of 0 votes
Answersgiven a matrix and a target, return if there is a path who’s sum is == target
- ajay.raj July 14, 2017 in United States
Input: matrix, integer output: true or false;| Report Duplicate | Flag | PURGE
Facebook SDE1 - 0of 0 votes
Answerspermute the String including case change
- ajay.raj July 14, 2017 in United States
"abc".
For example:
abc
ABC
Abc
aBc
abC
ABc
abC
AbC| Report Duplicate | Flag | PURGE
Facebook SDE1 - 0of 0 votes
Answersimplemnt JSON.stringify()
- ajay.raj July 14, 2017 in United States| Report Duplicate | Flag | PURGE
Facebook SDE1 - 0of 0 votes
AnswersCan you achieve the following without using enums? Given the last two lines stay the same.
- programmer July 12, 2017 in United Statesenum DayHalf { AM,PM; DayHalf dh1=DayHalf.AM; DayHalf dh2=DayHalf.PM; }
| Report Duplicate | Flag | PURGE
Facebook Java Developer - 1of 1 vote
AnswersConsider an implementation of Strings consisting of an array where the first element of the array indicates the length of the String and the next elements represent the value of the ASCII characters in the String. Implement String concatenation and discuss shortcomings of this operation under this implementation of Strings.
- funk July 05, 2017 in United States for Infrastructure| Report Duplicate | Flag | PURGE
Facebook Software Developer - 0of 0 votes
AnswersSuppose that there exists a service to fetch Facebook posts through an interface defined by you, design the Facebook wall feed.
- funk July 05, 2017 in United States for Infrastructure| Report Duplicate | Flag | PURGE
Facebook Software Developer - 2of 2 votes
AnswersGiven an array of ints and a value X, find wether there are 3 elements in the array such that their sum is X (return true/false).
- funk July 05, 2017 in United States for Infrastructure| Report Duplicate | Flag | PURGE
Facebook Software Developer - 0of 0 votes
AnswersGiven two vectors that might be sparse, calculate their Dot product. You can assume any data structure to represent the vectors.
- funk July 05, 2017 in United States for Infrastructure| Report Duplicate | Flag | PURGE
Facebook Software Developer - 0of 0 votes
AnswersGiven a matrix of characters where '_' represents an empty space, 'T' is a tree and 'H' is a house and a coordinate of that matrix, find the sum of the minimum distances from that coordinate to each house when considering that you can move through empty spaces and houses but not through trees.
- funk July 05, 2017 in United States for Infrastructure| Report Duplicate | Flag | PURGE
Facebook Software Developer - 0of 0 votes
AnswersReverse a linked list.
- funk July 05, 2017 in United States for Infrastructure| Report Duplicate | Flag | PURGE
Facebook Software Developer - 0of 0 votes
AnswerGiven two tree nodes and the root of a tree, find the distance between both nodes in the tree.
- funk July 05, 2017 in United States for Infrastructure| Report Duplicate | Flag | PURGE
Facebook Software Developer - 0of 0 votes
AnswersGiven a String that contains parenthesis, remove the least amount of parenthesis from it such that it becomes balanced.
- funk July 05, 2017 in United States for Infrastructure| Report Duplicate | Flag | PURGE
Facebook Software Developer