Neww5b5768me8

To what extent do people who crush Google/FB onsites validate/test their algorithm at the end?

I keep hearing about having tests at the end to validate your algorithm at the end of a coding round. But I have found in the past that just getting the right implementation and then walking through it with an example input is sufficient. People are making it sound like they literally write unit tests and test methods, and test with multiple example inputs. I just find that extremely hard to believe, especially when in my experience, the interviewer is very excited when you have performed well and successfully implemented the correct approach, and they glance over verification/testing so that you have enough time to ask them questions so they can sell you on the role. For those of you claiming you must write out unit tests / test methods, what does that even look like for you? Can you provide an example in comments?

Poll
55 Participants
Select only one answer
Microsoft Knrm08 Oct 1, 2021

Instead of just a verbally walkthrough, execute your source code function with multiple inputs which would cover the edge cases.

New
w5b5768me8 OP Oct 1, 2021

Gotcha, that makes sense. But what if you can't compile/execute (as in Google Doc / notepad screen share)? That's fairly common in my experience.

Amazon 🥜🍌69 Oct 1, 2021

Both FB and G don’t allow code execution, so this is garbage advice

Amazon 🥜🍌69 Oct 1, 2021

You don’t need to run through your solution line by line, but you should at least mention to the interviewer what you’re testing/concerned about and then run it through mentally.

Google swe-4.5 Oct 1, 2021

It’s better to run line by line, not just for the interviewer but you may find genuine bug. When mentally checking we skip details.

The Climate Corporation TSTk67 Oct 1, 2021

If you can call out the edge cases you're anticipating ahead of time, they like that. Then you just verbally run thru those examples quickly and usually they move on cause there's a follow up question coming

Amazon jWjS73 Oct 1, 2021

Every on-site I have been from Twitter , LinkedIn , ByteDance recently all made me run code with multiple test cases , in all rounds

New
w5b5768me8 OP Oct 1, 2021

What do you mean multiple test cases. As in executing the code with different sets of input values to test against different edge cases?

Amazon jWjS73 Oct 1, 2021

Yep they made me write a custom code and provide different input and check my actual function output

Amazon jdjslsko Oct 1, 2021

Think of edge cases before your interviewer comes up with it and then walk it through your code. Recently received google L4 by following this

Facebook bbki Oct 1, 2021

Do a mini proof by induction. Prove it works for case case, then prove given it works for previous case, it works for next case. Also pay lip service to nulls etc.

Microsoft zhwud2 Oct 1, 2021

Wtf advices people are throwing here. Proof of induction, write UTCs, execute code.. wtf.. Just take 2 3 inputs as examples and go thru them..lol

The Climate Corporation TSTk67 Oct 1, 2021

Yeah idk where that came from... proof by induction is probably a bad move unless you're sure it's a recursive/DP problem. Even then it's possible to fall into traps if you're not careful