# Facebook Interview Questions Set 5

Facebook latest placement papers of December are listed in Indiahires.in. Get your latest Facebook placement questions from Indiahires.

Q1. Convert a binary tree to a doubly circular linked list.

Q2. The only difficulty u will Facebook to get into Facebook is 1st round itself because u r supposed to code 3 questions in 90 minutes.

Q3. Cant point my finger at any one of them.

Q4. Given a binary tree, write a function that prints all of the paths from the root node to the leaf nodes. What are the functions’ run time and space requirements?

Q5. Given a linked list, where the value of each node can itself be a linked list (a recursive linked list), write a function that flattens it.

Q6. Basic data structure-based coding problem. Had to solve the problem and discuss run time and optimizations using another data structure.

Q8. You are given a bunch of dominoes. Write a function that determines if any two of those dominoes add up to [6, 6] (e.g. [1,4] + [5, 2]).

Q9. Create a linked list with 3 chars (A, B, C) in it and print the list in reverse.

Q10. Given two BST, return true if they have the same variable, and false if not.

Q11. Design an API for a news feed

Q12.  Find the shortest subtree that consists of all the deepest nodes. The tree is not binary.

Q13. Given an array of positive ints and a target, check to see if any consecutive sum in the array can add up to the target

Q14. Asked me how to reverse a Linked List. Recursive Solution, Non-Recursive Solution, edge cases.

Q15. Given a matrix of 1s and 0s, find the shortest route between two points in the matrix while considering 1s as walls and 0s as traversable paths.

Q16. Given an unsorted string, determine if it can be presented as a palindrome. MMO-True, DOOR-False

Q17. You have a 4 x 4 board with words. For example:

A B G H

O L L E

E R T Y

G E F Y

You need to write a function that finds if a certain word exists on the board. The rules are as followed:

1. Each character needs to be close to one other (neighbor cell). For example, The function will return false for the word HERE but true for the word.

Q18. Give the count and the number following in the series.

for e.g 1122344

first line output: 21221324

next line: 12112211121214 and so on.

Q19. Given an array of integers, return the length of the longest increasing subarray.

Q20. Difference between a file and an inode?

Q21. With a tree write a program to double the value of each node.

Q22. Write a function to find how many valid letters are in a string of digits give the mapping:

a -> 1

b -> 2

z – > 26

ex) 123 =>1, 12, 23 => a, l, w

Q23. Given two sorted input arrays that contain a two-element array of [key, value], write a function that multiplies the two arrays together and sums them where the “key” matches. Example: “v1 = [[1, 3], [2, 4], [99, 3]]; v2 = [[2,3],[5,9],[99,1]]” results in “15”. I first brute-forced it with O(n*m) then used two pointers which resulted in O(n+m) then he asked me to write it in O(n log m). I could not think of an algorithm at the time for O(n log m).

Q24. Take binary expansions as strings, and return the string containing their sum: add(“10010”, “101”) = “10111”.