## Facebook Interview Questions

- 0of 0 votes
given a list of numbers, put with + - * / any two number, find the maximum value you can get.

int getMaxNumber(int[] nums){

}

- 0of 0 votes
Given a group of movies and their start time, assuming that are 1 hour long,

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) {

}

- 2of 2 votes
3.1 design: design fb inbox search —> just focus on the post

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.

- 1of 1 vote
2.1 career discussion

2.2 divide two numbers with no / or %

- 2of 2 votes
1/4 round of FB on-site interview, Master Degree, Hired

1.1 diameter of tree

1.2 find the point which have the maximum overlap of intervals

- 0of 0 votes
friend circle. Given a streaming pairs representing friend relationship

(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){

}

- 0of 0 votes
For given list of numbers find out triplets with sum 0

Input : arr[] = {0, -1, 2, -3, 1}

Output : 0 -1 1

2 -3 1

- 0of 0 votes
Given a String and dictionary of words, break the string in minimum space sentence.

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.

- 0of 0 votes
given a matrix and a target, return if there is a path who’s sum is == target

Input: matrix, integer output: true or false;

- 0of 0 votes
permute the String including case change

"abc".

For example:

abc

ABC

Abc

aBc

abC

ABc

abC

AbC

- 0of 0 votes
implemnt JSON.stringify()

- 0of 0 votes
Can you achieve the following without using enums? Given the last two lines stay the same.

`enum DayHalf { AM,PM; DayHalf dh1=DayHalf.AM; DayHalf dh2=DayHalf.PM; }`

- 1of 1 vote
given a string of number, you can add a + or * sign between any two numbers, find the maximum value you can get

ex. s = "89" --> 8 * 9 = 72

int maxNumber(String s){}

- 1of 1 vote
Consider 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.

- 0of 0 votes
Suppose that there exists a service to fetch Facebook posts through an interface defined by you, design the Facebook wall feed.

- 2of 2 votes
Given 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).

- 0of 0 votes
Given two vectors that might be sparse, calculate their Dot product. You can assume any data structure to represent the vectors.

- 0of 0 votes
Given 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.

- 0of 0 votes
Reverse a linked list.

- 0of 0 votes
Given two tree nodes and the root of a tree, find the distance between both nodes in the tree.

- 0of 0 votes
Given a String that contains parenthesis, remove the least amount of parenthesis from it such that it becomes balanced.

- 2of 4 votes
Master Degree 2 year exp

1st Round.

Behavioral - most challenging project.

Tech - bit manipulation

2nd Round. A matrix has 0s and 1s only.. All the 1s in every row are to the of 0s. Find out the leftmost 1 in the entire matrix.

3rd Round.

A dp problem.

Find out how many ways you can make change of N cents given coins of values [a1, a2, a3...], each type of coin got infinite supplies.

Arrangement of coins don't matter.

4th Round.

Design news feed.

A user wrote a post with the basic user info, pictures and time etc (I even drafted a basic UI on whiteboard).

How to obtain these information and store them.

If a new feature with a button is added. How to maintain availability of old service to users who did not update the app.

Did not dive further into scaling.

5th Round.

User groups - If I made a certain post visible to a user group, how to store the post? how to push the post to the chosen group. If there are new friends who aren't assigned to any group just yet, how to treat them as if they were in the same 'unassigned' group?

DB sharding is involved.s

- 1of 1 vote
Find the length of longest arithmetic progression in array.

For example, in the array {1, 6, 3, 5, 9, 7}, the longest arithmetic sequence is 1, 3, 5, and 7

- 0of 0 votes
number_one = "193283492420348904832902348908239048823480823"

number_two = "3248234890238902348823940990234"

Question:

1) I need to multiply this and get the answer

2) DO NOT CONVERT TO INT AND DO THE MULTIPLICATION

- 0of 0 votes
I have two tables

Supplier Table:

Supp_id

supp_name

Invoice Table:

inv_id

supp_id

inv_date

inv_amt

payment_date

paid_amt

I want to list the invoice(s) that have highest invoice_amt for the year 2016.

DO NOT USE MIN/MAX function

- 0of 0 votes
Make 100 HTTP GET requests to http://en.wikipedia.org/wiki/Main_Page and print the following statistics for the response time to stdout:

• 10th, 50th, 90th, 95th, 99th Percentile

• Mean

• Standard Deviation

Your solution must be parallel. You must make at least N (say 10, but should be configurable). Use ExecutorService in Java for making the requests at a time.

Explain design choices, known limitations and edge cases.

What challenges did you face? How would you improve the code if you had more time?

- 0of 0 votes
Give you an unsorted integer iterator

and a percentage that is expressed in double (for example, 0.4 for 40%),

and find the number of the sorted array at the percentage position.

Example: Enter [1 3 2 5 4 6 7 9 8 10], and 0.6, you will return 6

public int findNumber(Iterator<Integer> nums, double percent){

}

- 0of 0 votes
can you use union find to Detect Cycle in a Directed Graph? why or why not

- 0of 0 votes
how to design github

- 0of 0 votes
Return the most popular 10 words in the past 24 hours for twitter

Follow up in order to reduce the size of each log, do not write timestamp, how to get the same answer,