Hacker News new | past | comments | ask | show | jobs | submit login

You would be surprised how hard it would be to invert a binary tree, or really just what the question is asking for, if you didn't at least study up on the concept in the last decade. It is conventional enough to sound mundane, but how often are we inverting binary trees in practice?



It came out that by inverting a binary tree just meant swapping the left and right children of all nodes of the tree. It's pretty much 'can you iterate through a tree?' which comes up a surprising amount.


Sure, but try coming up with that without even remembering what invert meant (it isn't a word that is commonly used in practice outside of CS education and l00tcode). Most of the problem in l00tcode question is just figuring out what is being asked for, not in doing the ask. That's why studying and understanding lots of l00tcode problems as prep is very effective (even if you haven't seen the problem, the problem is probably adjacent and you can understand it more quickly during the interview).


you can always ask interviewer - define invert what does it mean - and interviewer in 100% cases will explain and even provide test cases.

in fact any candidate that doesnt ask clarifying questions and goes deep into coding right away - has a chance of going into wrong direction and is flagged as red flag.

As an interviewer I always lookout for candidates that dont ask questions, dont start with test cases, assume in their mind what is their understanding of ideal solution - and start coding. These are very inexperienced people who do that


'Invert' is a pretty common word.


Yes but is it Referring to the additive or multiplicative inverse?

Or maybe it’s making the tree upside down, so all leaves become roots, and the root becomes a leaf. But when we do that, do we just invert all the edges or transform the whole tree?

Maybe it’s referring to changing a red-black tree into a green-white tree? Or turning a splay tree into a merge tree?


It can mean a lot of things, so you ask questions.

Howell (the homebrew 'google didn't hire me because of inverting a binary tree' guy) confirmed that they meant swapping right and left children of all nodes.


Yes, but the common slang it is used for isn't the meaning we are using for l00tcode questions.


There isn't one meaning in leetcode questions; it could mean a bunch of things. That's why you ask questions in an interview.


The common meaning isn’t slang. The (multiple!) math/CS senses of the word are jargon. Which is fine—nothing wrong with jargon—but their existence doesn’t make the ordinary sense slang.




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

Search: