Facebook | Phone | Word Break & Merge K Sorted Lists
Company: Meta (Facebook)
Role: e3
Interview Stage: Phone Screen
Location: unknown
Year: 2020
Original Post Content:
Position: SWE New Grad
Date: March 2020
你好!
I graduated May 2019 but they reached me out last week for a new grad role.
I recently had the interview with Facebook and wanted to share my interview questions.
The first one was the same as this one. https://leetcode.com/problems/word-break/
The second one was similar to this one. https://leetcode.com/problems/merge-k-sorted-lists/
We started directly with the coding and only spoke for 3-5 minutes in the end.
We did not discuss any of my experience/projects/etc...
At the moment, I haven't done neither of the problems.
The first one I got it "relatively" fast (about 15-20 mins) and he told me it was pretty good, so no further optimization was needed.
My approach was similar to the dynamic programming solution on the problem, but he told it was me to solve recursively and when I got it and fixed a couple of bugs, went to the next one.
The second one, was similar to merge k sorted lists, but it was descending order, and the vector<vector<struct>> had already each vector the stories sorted descending, it was with a custom struct, it did get me by surprise because (I don't know if I didn't understand or he wasn't clear enough, but even after I asked several questions, he was very ambiguous) I understood that he wanted me to return the "next" element id within the custom struct. ¿?
struct customstruct{
int id;
float score;
string content;
}
...
[
[.9, .2],
[.7, .5]
]
...
.9->.7->.5->.2
// Expected ans was return next ID of the elements in descending order
I choked a little bit, but I didn't get discouraged/unfocused, and got back on track after I asked him if I could implement it as a function.
I think I did solve the problem, but time ran out, he did praise me over "my vector knowledge and really quick programming abilities", but I think I didn't solved as expected.
I asked a couple of questions in the end, but it seems he already made a choice, so he wasn't very into it.
After waiting for a couple of weeks with no answer, I sent an email to the recruiter.
It was no for me.
Good luck interviewing.