Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Oh no, that bit's easy.

But you don't ask them "swap the left and right field in each node". You ask them to "invert a binary tree".

Why. The Fuck. Does "invert a binary tree" mean "swapping the left and right fields"?

To me, it means inverting the relationship so child points to parent, which would end up badly-defined, there would be no way to uniquely specify a root. But if you don't know that knowledge, of what the jargon means, you're screwed. So that's what you're testing for.



Are you imagining a scenario where the interviewer writes "invert a binary tree" on the whiteboard, refuses to elaborate and leaves the room for half an hour?

In real life they would either give you an example so you can better understand the requirements or expect you to come up with an example yourself and ask clarifying questions until you're on the same page as to what "invert" means.


Sure, in that case it may be a bit unfair. I was looking at the leetcode thingy where they just give you an existing data structure, some sample in- and outputs, and just ask you to write the inversion algorithm. I assume it would be like that in most job interviews.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: