Facebook | Phone | Flatten a multi-dimensional array & Implement Debounce

Hello I would like to share a Facebook phone screen for a front end software engineer role at Seatle.
I did it at end of April. The language I choosen is Javascript.

The 1st question is:
Given a multi d array, return a new flaten array.
Example: [1, [2, 3], [[4]]] should return [1, 2, 3, 4].
My solution: Just as someone wrote on StackOverFlow I did a recursion and using Array.reduce() method.
Followup: The input array can be really deep. What's the drawback of recursion?? Can you do it without using recursion?? Also can you do it without using Stack data structure??
I would say the last question on follow up I got stuck a bit and figure out the solution with some hint.

The 2nd question is:
Implement a debounce from scratch.
My solution: TBH I didn't prepare this at all, my intuitive solution is using a combination of Javascript closure and setTimeout() function. The interviewer said he's good with my solution, so i went ahead and finished coding.
No follow up question on this.

In the end 5min I asked some cultural related question.
Overall the conversation is pleasant. However I received a rejection in the next week, the recruiter said she cannot provide any feedback for the hiring decision, and cooling off time is at least a year. It sounds really unfortunate.

Hope this helps!

Comments (10)