Facebook Interview Questions
- 1of 1 vote
AnswersAdd two numbers represented as LinkedList (not LeetCode 445 which uses ListNode)
- KelvinLong8897 November 17, 2018 in United States
e.g
inputs: '5'->'6'->'3'
'8'->'4'->'2'
output: '1'->'4'->'0'->'5'
method signature:
LinkedList<Integer> sumList(LinkedList<Integer> l1, LinkedList<Integer> l2)| Report Duplicate | Flag | PURGE
Facebook Android Engineer Algorithm - 3of 3 votes
AnswersYou have two sorted arrays, where each element is an interval. Now, merge the two array, overlapping intervals can be merged as a single one.
- Seetha November 11, 2018 in United States
I/P :
List 1 [1,2] , [3,9]
List 2 [4,5], [8, 10], [11,12]
O/P [1,2], [3,10], [11,12]| Report Duplicate | Flag | PURGE
Facebook Software Developer - 0of 0 votes
AnswersI/P [8, 3, 2, [5, 6, [9]], 6]
- Seetha November 11, 2018 in United States
O/P 8+3+2+2*(5+6+3*(9))+6 => 95| Report Duplicate | Flag | PURGE
Facebook Software Developer Arrays - 1of 1 vote
Answersfind all numbers the sum of cube of each digits is the number itself
- Aamir November 09, 2018 in United States
ex:153=1^3+5^3+3^3| Report Duplicate | Flag | PURGE
Facebook Software Engineer Intern - 0of 0 votes
AnswersYou are given an array A of size N and Q queries. For each query, you are given two indices of the array L and R. The subarray generated from L to R is reversed. Your task is to determine the maximum sum of the subarrays.
- Sameer October 29, 2018 in United States
Note: After each query is solved, the array comes to its initial states.
Input format
First line: Two space-separated integers N and Q
Next line: N space-separated integers denoting the array elements.
Next
Q lines: Two space-separated integers in every line denoting the values of Li and Ri
Output format
For each query, print the required answer in a new line.
5 2
3 -1 4 2 -1
3 4
1 2
//output
8
9| Report Duplicate | Flag | PURGE
Facebook Software Developer - 0of 0 votes
AnswersConvert infix to postfix and evaluate postfix expression.
- user October 28, 2018 in United States
For example: 4 // number of variables
g = 2
p = 3
t = 1
w = 2
3 // number of equations
g + p x t - w x p
t - g + t - w
e + t x t - m
Output: -1 //for first equation
-2 //for second equation
Compilation Error // for third equation| Report Duplicate | Flag | PURGE
Facebook Testing / Quality Assurance - 0of 0 votes
AnswersConvert infix to postfix and evaluate postfix expression.
- user October 28, 2018 in United States
For example: Input:
3 // number of variables
a = 1
b = 2
c = 2
2 // number of equations
a x b + a x c + b x c
a x c - b / c + c x c
Output: 8 //for first equation
5 // for second equation| Report Duplicate | Flag | PURGE
Facebook Testing / Quality Assurance - 1of 1 vote
AnswersHow to evaluate a mathematical expression by compiler design. The program will ask the user to input a value (say n). Then user will input n lines of input each of which contains an identifier and its corresponding value. Then program will ask the user again to input a value (say m). Then user will input m lines of expressions. Calculate the final value for each of the given expression using first n lines of input. If you can't evaluate any expression from given numbers of identifiers then output 'Compilation Error'. Allowed mathematical operators are +(add), -(subtract), x(multiply), /(divide).
- user October 27, 2018 in United States
Example: a = 1
b = 2
c = 2
a x b + a x c + b x c output 8
a x c - b / c + c x c out put 5
g = 2
p = 3
t = 1
w = 2
g + p x t - w x p output -1
t - g + t - w output -2
e + t x t - m output compilation error| Report Duplicate | Flag | PURGE
Facebook Software Engineer - 2of 2 votes
AnswersGiven the root of a binary tree, print the nodes column wise and row wise.
..............6 ............/....\ ...........9......4 ........../..\......\ .........5....1.....3 ..........\........./ ...........0.......7
The answer would be 5 9 0 6 1 4 7 3.
- Champaklal October 26, 2018 in United States| Report Duplicate | Flag | PURGE
Facebook Software Developer Algorithm - 1of 1 vote
AnswersGiven 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.
- MM2181 August 19, 2018 in United States| Report Duplicate | Flag | PURGE
Facebook Web Developer - 2of 2 votes
AnswersGiven an integer, print an English phrase that describes the integer (eg, "Two hundred and thirty four", “One Thousand, Two Hundred and Thirty Four”)
- MM2181 August 19, 2018 in United States| Report Duplicate | Flag | PURGE
Facebook Web Developer - 2of 2 votes
AnswersYou 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.
- MM2181 August 19, 2018 in United States| Report Duplicate | Flag | PURGE
Facebook Web Developer - 0of 0 votes
Answerswrite a class that 1) calculates the average of the stream, 2) provides an API read the average.
- samayragoyal990 August 10, 2018 in United States
Handle overflows as the numbers can be very large and not fit into double/long.| Report Duplicate | Flag | PURGE
Facebook SDE-3 Coding - 0of 4 votes
AnswersGiven an array of lower case strings, the task is to find the number of strings that are special equivalent.
- boony August 09, 2018 in United States
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| Report Duplicate | Flag | PURGE
Facebook Software Engineer - 2of 2 votes
AnswersGiven 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.
- Scott.T.Rogers July 06, 2018 in United States| Report Duplicate | Flag | PURGE
Facebook Senior Software Development Engineer Algorithm - -4of 6 votes
Answerword look up
- bryan July 06, 2018 in United States| Report Duplicate | Flag | PURGE
Facebook Data Structures - 2of 2 votes
AnswersI was asked to design a system on a whiteboard which simulate a executor.
- Patrick July 01, 2018 in United States
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| Report Duplicate | Flag | PURGE
Facebook Software Developer Java - 5of 5 votes
AnswersCongrats on aonecode member A.P. for signing the offer with FB! Thanks for sharing the experience with us.
- aonecoding May 24, 2018 in United States
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| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 1of 1 vote
AnswersGiven 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).
- sarunreddy82 May 13, 2018 in United States
Examples:
next_permutation (12) = 21
next_permutation (315) = 351
next_permutation (583) = 835
next_permutation (12389) = 12398
next_permutation (34722641) = 34724126| Report Duplicate | Flag | PURGE
Facebook Java - -5of 5 votes
AnswersIf b == “1”:
- TubbyOPPO May 09, 2018 in England
quit()| Report Duplicate | Flag | PURGE
Facebook Software Engineer - 1of 1 vote
AnswersGiven a binary tree, where each node represents an integer, find the max value of path sum.
- LeetCoder May 07, 2018 in United States| Report Duplicate | Flag | PURGE
Facebook Android Engineer Trees and Graphs - 6of 6 votes
AnswersFB On-site March
- aonecoding April 21, 2018 in United States
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?| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 1of 1 vote
AnswersInterleave list of lists in Java
- npkatre102 April 18, 2018 in United States
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]| Report Duplicate | Flag | PURGE
Facebook Software Developer - 0of 0 votes
AnswersGiven an array of n elements return true if 3 of the sum of 3 elements is equal to a constant c
- mapardotl April 10, 2018 in United States for Facebook groups
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| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Java - 3of 3 votes
AnswersGiven 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.
- genaker April 05, 2018 in United States| Report Duplicate | Flag | PURGE
Facebook Software Developer - 2of 2 votes
AnswersGiven a collection of two dimensional points and a number k, return the k closest points to (0,0) by Euclidean distance.
- genaker April 05, 2018 in United States| Report Duplicate | Flag | PURGE
Facebook Software Developer - 1of 1 vote
AnswersGiven 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]
- ngupta32@hawk.iit.edu March 30, 2018 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm Coding Data Structures - 2of 2 votes
AnswersMove[inplace] the non zero elements at the one end(end of array) and return the numbers of non zero elements in output array
- rituraj.raj March 28, 2018 in India for London office
Solution : https://www.geeksforgeeks.org/move-zeroes-end-array/| Report Duplicate | Flag | PURGE
Facebook Android Engineer - 0of 2 votes
Answerwhat is UI/Main Thread in android.
- rituraj.raj March 28, 2018 in India for London office
when you can use Thread over Service| Report Duplicate | Flag | PURGE
Facebook Android Engineer - -2of 2 votes
AnswersQuestion 2: Given a number 'k', return the corresponding row, given the pattern:
- mche1987 March 27, 2018 in United States
k => output
0 => []
1 => ["0", "1", "8"]
2 => ["00", "11", "69", "96", "88"]
3 => ["000", "111", "101", "888", ...] // and so on ...| Report Duplicate | Flag | PURGE
Facebook SDE1 Algorithm