← Timeline

Need advice for onsite interview at Meta

r/leetcode

u/everythingBagel13 wrote (the comment Michael replied to):

How close is close? I believe I had optimal time but not optimal space and the follow up was to optimize space. I was able to get really close to a working solution after a hint from interviewer.

u/michaelnovati replied ·
Believe it or not they do want to hire people who are good engineers and not just perfectly solving leetcode problems :P I tell people the biggest complement they can get is if the interview says they have a "clean solution" or "clean code". Clean means: - no extra logic, extra if statements, extra variables, good naming, consistent styling, etc... - the conceptual approach is easy to follow, explained well, elegantly handles edge cases without a lot of special handling Often times "optimal space" and "optimal time" come from having a genuinely clean solution. Sometimes they require extremely complex and awkward optimizations that are very hard for someone to understand. So if the optimal solution is naturally "clean" then I think it's expected. If the optimal solution is extremely complex, then a super clean less optimal solution + good explanation for how to do the optimal is good. There aren't any official rules here, it takes some practice to get a sense of what these things mean, and maybe some day I'll write a longer post trying to elaborate more on these concepts.