Facebook Interview Questions
- 0of 2 votes
AnswersMastermind is a game of two players. In the beginning, first player decides a secret key, which is a sequence (s1,s2,...sk) where 0 < si <= n, Then second player makes guesses in rounds, where each guess is of form (g1,g2, ...gk), and after each guess first player calculates the score for the guess. Score for a guess is equal to number of i's for which we have gi = si.
- nilmish.iit October 26, 2012 in United States
For example if the secret key is (4,2,5,3,1) and the guess is (1,2,3,7,1),then the score is 2, because
g2 = s2 and g5 = s5.
Given a sequence of guesses, and scores for each guess, your program must decide if there exists at least one secret key that generates those exact scores.
Input
First line of input contains a single integer C (1 <=C <= 100). C test-cases follow. First line of each test-case contains three integers n,k and q. (1 <=n,k <=11, 1<=q<=8). Next q lines contain the guesses.
Each guess consists of k integers gi,1, gi,2,....gi,k separated by a single space, followed by the score for the guess bi (1 <= gi,j<=n for all 1 <=i <=q, 1 <=j <=k; and 0 <= bi <=k )
Output
For each test-case, output "Yes" (without quotes), if there exists at least a secret key which generates those exact scores, otherwise output "No".
Sample Input
2
4 4 2
2 1 2 2 0
2 2 1 1 1
4 4 2
1 2 3 4 4
4 3 2 1 1
Sample Output
Yes
No| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm - 3of 3 votes
AnswersYou are given an array of N elements.arrange array in such a way that sum of any cunsucative k numbers are divisible
- dilip kasana October 25, 2012 in India
by NUM.if not possible print -1.(it may possible that there are many solution possible then return any one)
For example:
N=6
k=3
NUM=63
array={80,17,90,82,27,19}
Answer:{19,17,27,82,80,90}
any 3 cunsucative no. like (27+82+80)%63=0
another solution={27,19,17,90,82,80}
may be a hint :try to group all no.'s in mod NUM map and use vector and map.| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm - 0of 0 votes
AnswersYou are given an array of integers. Find all the combinations of the numbers of the array, that sum to another number(might be different for different combination) from the array.
- Chen October 20, 2012 in United States
One property of the array: The maximum number of the array will not be much greater than the others.| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm - 0of 0 votes
AnswersGiven an array and a key, sum min subarray whose sum is no less than key. O(n) Time needed
- Steve October 14, 2012 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm - 0of 0 votes
Answerssingle machine,,given a dictionary(key->value),every entry takes 1KB,totally10 Million个entry,single mutex protecting the dictionary,mutex takes 512 Byte,What potential problems do you see and how would you address them?
- Steve October 13, 2012 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Application / UI Design - 0of 0 votes
AnswersImplement atof function. eg., +3.5e-2, .03e1, 1e1, 0.0
- Steve October 13, 2012 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm - 1of 1 vote
Answersgiving lots of intervals [ai, bi], find a point intersect with the most number of intervals
- Steve October 13, 2012 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm - 0of 0 votes
AnswersFInd the maximum sum of a sub-sequence from an positive integer array where any two numbers of sub-sequence are not adjacent to each other in the original sequence. E.g 1 2 3 4 5 6 --> 2 4 6
- Steve October 13, 2012 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm - 0of 0 votes
AnswersYou are given intervals of contiguous integers, like [1, 10), [15, 25), [40, 50), which are non-overlapping and of a fixed size.
- Steve October 13, 2012 in United States
Design a data structure to store these intervals and have the operations of insert, delete, and find functions| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Data Structures - 0of 0 votes
AnswersYou are going to take some numbers as an input from a file. You need to witer a program to find longest increasing sequence. You should process it as soon as you are taking an input. After finishing the last input immediately you should be able to tell the sequence. Input: 1 5 3 4 6 4 Output: 3 4 6
- Steve October 13, 2012 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm - 1of 1 vote
AnswersDesign the Facebook Credit system which is a application where users can buy/trade virtual currency and can use the virtual currency to purchase Facebook services, like paid apps.
- Steve October 13, 2012 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Application / UI Design - 0of 0 votes
AnswersDesign and implement an algorithm that would correct typos: for example, if an extra letter is added, what would you do?
- Steve October 13, 2012 in United States
design and implement algorithms that correct typos, offering guidance, encouragement, and confirmation along the way| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Application / UI Design - 1of 1 vote
AnswersA period of time where users login and logout, given a sets of login and logout time pairs, write a function that can show the number of users online at any given time.
- Steve October 08, 2012 in United States| Report Duplicate | Flag | PURGE
Facebook Algorithm - 1of 1 vote
AnswersImplement a read/write lock, given a mutex that has lock() and trylock() interface
- Steve October 08, 2012 in United States| Report Duplicate | Flag | PURGE
Facebook Application / UI Design - 1of 1 vote
AnswersGenerate a random 4 letter word from /usr/share/dict/words
- Steve October 05, 2012 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm - 0of 0 votes
AnswersA file contains a billion integers, try to find any one integer that is not in the file.
- Steve October 05, 2012 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Application / UI Design - 0of 0 votes
AnswersHow would you implement hash table on your own? Write the code for implementing your own hash table?
- Steve October 05, 2012 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Data Structures - 0of 0 votes
AnswersIf you wanted to make a highly concurrent cache with a least recently used replacement policy, what data structures would you use? How would this scale per number of threads?
- Steve October 05, 2012 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Data Structures - 0of 0 votes
AnswersGiven a string and a pattern('.' Matches any single character.'*' Matches zero or more of the preceding element.), find the first substring matching this pattern.
- Steve October 01, 2012 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm - 0of 0 votes
Answer• Design the recommendation system for search keywords
- Steve September 25, 2012 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Application / UI Design - 0of 0 votes
Answers• Design a system to support Facebook status update
- Steve September 25, 2012 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Application / UI Design - 0of 0 votes
AnswersDesign a system for showing quotes on the web?
- Steve September 24, 2012 in United States
For example, when the user is looking at page A, part of which is reproduced in page B, the system could highlight part of page A present the user with a link to page B.
What constitutes a quote?
How do you find quotes?
How do you make it scale to the web?
How do you handle updates?
How would you arrange the servers?
What data structures would you use?| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Application / UI Design - 0of 0 votes
AnswersFB has decided to award user who submits the billionth search query on a given day a car, by showing them a banner on their search result page. How would you implement such a system?
- Steve September 23, 2012 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Application / UI Design - 0of 0 votes
AnswersGiven a set {1,2,3,4,5...n} of n elements, write code that outputs all subsets of length k. For example, if n = 4 and k = 2, the output would be {1, 2}, {1, 3}, {1, 4}, {2, 3}, {2, 4}, {3, 4}
- software engineer September 22, 2012 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm - 0of 0 votes
Answersdesign the backend system(data structure) of facebook's "like" button
- Steve September 19, 2012 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Application / UI Design - 0of 0 votes
AnswersDetermine winner of 2/9 number game
- Steve September 16, 2012 in United States
Two players play the following game: they pick a random number N (less than 2 billion) then,
starting from 1, take turns multiplying the number from the previous turn with either 2 or 9 (their choice).
Whoever reaches N first wins.
The candidate should write a function that given N decides who wins (first or second player)?| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm - 0of 0 votes
Answersdesign a distributed system to find the 1000th visitor of google.com
- Steve September 14, 2012 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Application / UI Design - 2of 2 votes
AnswersDesign the backend for a Gmail-like mail system
- Steve September 14, 2012 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Application / UI Design - 0of 0 votes
Answersdesign and implement a memcache
- Steve September 14, 2012 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer System Design - 0of 0 votes
AnswersDesign a DHT
- Steve September 14, 2012 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Application / UI Design