Interviewers at FAANG and others, which of the following do you prefer? 1) Flawless working code, all edge cases handled. Complexity say O(N^2) for both time and space 2)Optimized working code but with some minor coding errors, no bug in algo design. Complexity say O(NlogN) for time and O(N) for space. Question involved isn't straightforward leetcode/sorting thing. Let's say something to do with string and suffix arrays. Have an interview scheduled next month so looking to find out what to focus on. Any help appreciated.
1 not 2.
I would pick 2
O(N^2) doesn't doesn't work at scale. Focus on optimizing your code. But also, you really should be able to implement things flawlessly
Very true
O(N^2) is a long term maintainability disaster waiting to happen. Fix your bugs and keep things simple.
My code was never perfect in any of my FANG interviews.
Lol, you’d fail at design - posting a subjective question without a poll
I think in reality flawless code on a whiteboard is overrated. You might find an asshole interviewer or a case where they ask you an easy question (DFS/BFS like) and expect you to be perfect, but I think on the typical case if you write code that gets there even if at the end there’s some rough edges the interviewer might point them out and you’ll need to be ready to recognize and fix and you’ll be fine then. If you struggled along the way though the errors at the end might be evaluated more harshly
Can't say about all FANG but non-optimal solution is unlikely going to pass in Facebook