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

To change the nodes to point the other way around. So if the left edge of N1 points to N2 and the right edge points to N3 you make it so that N1's left edge points to N3 and the right edge points to N2. It's a trivial problem of changing pointers around. It's like 4 or 5 lines of code if you write a recursive function.



    def invert(node):
        if node is None: return
        invert(node.left)
        invert(node.right)
        node.left, node.right = node.right, node.left
Yep, pretty much. But, to be honest, if you hadn't described it I wouldn't have had a clue what was meant by inverting a tree. Zippering it or something? I wouldn't know.


You can ask the interviewer to clarify what the question is or what the result should look like. You should always ask for more details ask if you don't understand the question, and sometimes people ask in a vague way to see if the candidate will ask for clarification for better or for worse. It will not make you look stupid.

The simple action of saying "I don't know what you mean by X" or "I don't understand what X is" builds up your credibility, not reduce it. People who aren't afraid to ask questions demonstrate credibility because when they do say they know something you know they probably actually do.

I have learned so much from not being afraid to say "What is X" when someone starts talking to me about something and assume I know what it is already.

Nobody has ever laughed at me for this. Even if they did, it wouldn't bother me, because I'd rather I look silly and then learn what it is than to pretend I know and then actually end up not learning what it was someone was talking to me about.

Finally if they did think you should have known what the topic was you'd rather they know that about you while they're evaluating you not after you're hired and end up in over your head. This is a really unlikely scenario. These interviews are not so much about what you know, but how you solve problems.




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

Search: