Facebook Interview Questions
- 0of 0 votes
AnswersGiven a
struct drop{ float x_cordinate; float radius; }
Return the number of calls that the function Drop() that returns a drop object, needs to be called so that the interval [0, 1) is covered. For each drop object the range covered are values on a line considering x_cordinate as center and radius as the length added on both sides of the x_cordinate on that line?
int numCalls(const function<drop> Drop){ drop firstDrop = Drop(); // Code from here }
For example, if the first Drop() call returns drop object drop.location as 0.5 (considering points on a 1d axis) and drop.radius as 0.2, then the interval covered is [0.3, 0.7). So how many calls need to be made to ensure the interval [0, 1) is covered. The location and radius can map to any real value.
- rahul January 21, 2019 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer Intern - 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
Answers# Given a dictionary, find all pairs of words that,
- nico.campolongo February 16, 2018
# when concatenated together, form a palindrome.
# ‘none', 'xenon': 'nonexenon' is a palindrome
# 'none', 'xexenon': 'nonexexenon' is a palindrome| Report Duplicate | Flag | PURGE
Facebook Software Engineer Intern - 0of 0 votes
AnswersInsert node with a given value in a circular sorted linked list.
- sbdul May 10, 2017 in UK| Report Duplicate | Flag | PURGE
Facebook Software Engineer Intern - 0of 0 votes
AnswersGiven list of N points find the K closest points to origin i.e((0,0)).
- sbdul May 10, 2017 in UK| Report Duplicate | Flag | PURGE
Facebook Software Engineer Intern - 1of 1 vote
AnswersInterview Question: essentially given a bunch of sets in an array, print out the cross product of all of those sets
- ul December 22, 2016 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer Intern - 4of 4 votes
AnswersGiven the root of a binary tree containing integers, print the columns of the tree in order with the nodes in each column printed top-to-bottom.
- takepwn February 26, 2016 in United StatesInput: 6 / \ 3 4 / \ \ 5 1 0 / \ / 9 2 8 \ 7 Output: 9 5 3 2 6 1 7 4 8 0 Input: 1 / \ 2 3 / \ / \ 4 5 6 7 When two nodes share the same position (e.g. 5 and 6), they may be printed in either order: Output: 4 2 1 5 6 3 7 or: 4 2 1 6 5 3 7
| Report Duplicate | Flag | PURGE
Facebook Software Engineer Intern Trees and Graphs - 2of 2 votes
AnswersGiven two arrays/Lists (choose whatever you want to) with sorted and non intersecting intervals. Merge them to get a new sorted non intersecting array/list.
- HumbleLearner February 12, 2016 in United States
Eg:
Given:
Arr1 = [3-11, 17-25, 58-73];
Arr2 = [6-18, 40-47];
Wanted:
Arr3 = [3-25, 40-47, 58-73];| Report Duplicate | Flag | PURGE
Facebook Software Engineer Intern Algorithm - 3of 3 votes
AnswersTask schedule: given a sequence of task like A B C(means 3 different tasks), and a coldtime, which means you need to wait for that much time to start next [same] task. Now----
- songty11 January 27, 2016 in United States
Input: string, n
Output: the best task-finishing sequence.
eg. input: AAABBB, 2
Output: AB_AB_AB
( "_" represents do nothing and wait)| Report Duplicate | Flag | PURGE
Facebook Software Engineer Intern Algorithm - 0of 0 votes
AnswersGiven n, return 1 ^ 2 ^ 3 ^ ... ^ n
Where ^ is binary xor.
Note: n is a 64-bit number, and 1<<63 is a valid n for this problem.
Examples:
- emb October 07, 2015 in United States>>> reduce(lambda a,b:a^b, [1,2,3]) 0 >>> reduce(lambda a,b:a^b, [1,2,3,4]) 4 >>> reduce(lambda a,b:a^b, [1,2,3,4,5,6,7]) 0 >>> reduce(lambda a,b:a^b, [1,2,3,4,5,6,7,8,9]) 1
| Report Duplicate | Flag | PURGE
Facebook Software Engineer Intern - -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 - 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 - 2of 2 votes
AnswersGiven an array of integers, return true if there're 3 numbers adding up to zero (repetitions are allowed)
- fatenuller January 09, 2015 in United States
{10, -2, -1, 3} -> true
{10, -2, 1} -> true -2 + 1 +1 =0| Report Duplicate | Flag | PURGE
Facebook Software Engineer Intern Algorithm - 2of 2 votes
AnswersPrint a BST such that it looks like a tree (with new lines and indentation, the way we see it in algorithms books).
- Ray December 22, 2014 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer Intern Algorithm - 2of 2 votes
AnswersWrite a function that takes the following inputs and gives the following outputs.
- forfron December 19, 2014 in United States
Input: A list of points in 2-dimensional space, and an integer k
Output: The k input points closest to (5, 5), using Euclidean distance
Example:
Input: {(-2, -4), (0, 0), (10, 15), (5, 6), (7, 8), (-10, -30)}, k = 2
Output: {(5, 6), (7, 8)}| Report Duplicate | Flag | PURGE
Facebook Software Engineer Intern Algorithm - 4of 4 votes
AnswersGiven a list of strings, return a list of lists of strings that groups all anagrams.
- tirelative December 13, 2014 in United States
Ex. given {trees, bike, cars, steer, arcs}
return { {cars, arcs}, {bike}, {trees, steer} }
m = # of words
n = length of longest word
I solved this in O(m * n * log n) time.| Report Duplicate | Flag | PURGE
Facebook Software Engineer Intern Algorithm - 7of 7 votes
AnswersGiven an array of integers.
- Victor November 27, 2014 in United States
Move all non-zero elements to the left of all zero elements.| Report Duplicate | Flag | PURGE
Facebook Software Engineer Intern Algorithm - 2of 2 votes
AnswersThere's a new language which uses the latin alphabet. However, you don't know the order among letters.
- Victor November 27, 2014 in United States
It could be:
a b c d ...
as it could also be:
b e z a m i ...
You receive a list of words lexicographically sorted by the rules of this new language. From this list, derive one valid particular ordering of letters in this language.| Report Duplicate | Flag | PURGE
Facebook Software Engineer Intern Algorithm - 3of 3 votes
AnswersYou're given a dictionary of strings, and a key. Check if the key is composed of an arbitrary number of concatenations of strings from the dictionary. For example:
- davelee71047 October 25, 2014 in United States
dictionary: "world", "hello", "super", "hell"
key: "helloworld" --> return true
key: "superman" --> return false
key: "hellohello" --> return true| Report Duplicate | Flag | PURGE
Facebook Software Engineer Intern Algorithm - 3of 5 votes
AnswersA professor wants to see if two students have cheated when writing a paper. Design a function : hasCheated(String s1,String s2, int N) that evaluates to true if two strings have a common substring of length N. Additional question after implementation. Assume you don't have the possibility of using String.contains() and String.substring(). How would you implement this?
- dke.ade February 25, 2014 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer Intern Java - 4of 4 votes
AnswersGiven a list of 4 billion integers, find an integer not in the list using 4MB of memory. (interview was in Java)
- dke.ade February 25, 2014 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer Intern Java - 4of 4 votes
AnswersWrite atof in Java, which converts a string representation of a float (like "342.18E-10") to an actual float without using any built-in parsing functions.
- dke.ade February 25, 2014 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer Intern Algorithm - 3of 5 votes
AnswersGiven a Binary Tree (balanced or not) write a method that transforms the tree in a degenerate tree (basically a data structure like a sorted linked list where each node has the left child null) and returns the new root. This must be made in place, no external memory usage is allowed.
- Ray February 23, 2014 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer Intern Trees and Graphs - 2of 4 votes
AnswersIn Java: Write a function in language of your choice that takes in two strings, and returns true if they match. Constraints are as follows: String 1, the text to match to, will be alphabets and digits. String 2, the pattern, will be alphabets, digits, '.' and '*'. '.' means either alphabet or digit will be considered as a "match". "*" means the previous character is repeat 0 or more # of times. For example: Text: Facebook Pattern: F.cebo*k returns true.
- dke.ade February 13, 2014 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer Intern Algorithm - 4of 4 votes
AnswersPrints all unique subsets of the string.
- mabodx February 11, 2014 in United States
Given a string write a function which prints all the subsets of the string. Now make the function to return only unique solutions.| Report Duplicate | Flag | PURGE
Facebook Software Engineer Intern Algorithm - 7of 7 votes
AnswersGiven a regular expression with characters a-z, ' * ', ' . '
- kevin October 13, 2013 in United States
the task was to find if that string could match another string with characters from: a-z
where ' * ' can delete the character before it, and ' . ' could match whatever character. ' * ' always appear after a a-z character.
Example:
isMatch("a*", "") = true;
isMatch(".", "") = false;
isMatch("ab*", "a") = true;
isMatch("a.", "ab") = true;
isMatch("a", "a") = true;| Report Duplicate | Flag | PURGE
Facebook Software Engineer Intern Algorithm - 1of 3 votes
AnswersYou are given an array of 1's 2's and 3's. Sort this list so the 1's are first, the 2's come second, and the 3's come third.
- Aasen May 23, 2013 in United States
Ex: Input [1, 3, 3, 2, 1]
Output [1, 1, 2, 3, 3]
But there is a catch!! The algorithm must be one pass, which means no merge/quick sort. Also no extra list allocations are allowed, which means no bucket/radix/counting sorts.
You are only permitted to swap elements.| Report Duplicate | Flag | PURGE
Facebook Software Engineer Intern Algorithm - 2of 2 votes
AnswersGiven an virtual 4x4 boggle board, and some 4 letter words, determine if the words are in the board
- rosie March 22, 2013 in United States
ex.
S M E F
R A T D
L O N I
K A F B
STAR- no
TONE- no
NOTE- yes
SAND- yes
etc.| Report Duplicate | Flag | PURGE
Facebook Software Engineer Intern