(no title)
Jasper_ | 1 year ago
The best anyone can figure out is that it's reversing the left and right branches, which seems like it's ten lines of code, at most?
Jasper_ | 1 year ago
The best anyone can figure out is that it's reversing the left and right branches, which seems like it's ten lines of code, at most?
Liquix|1 year ago
[0] https://leetcode.com/problems/invert-binary-tree/description...
[1] https://x.com/mxcl/status/608682016205344768
devmor|1 year ago
When my team conducts technical interviews, we are asking for a couple simple programming solutions - but we're asking because we want to hear the candidate talk through it and see what their problem solving process is like.
If you aren't evaluating based on conditions like those, I don't really see the value of coding questions.
emmanueloga_|1 year ago
In terms of the problem itself, a binary tree can be expressed something like:
Given a root, you can invert it recursively with some code like this: Or using an explicit stack: I think without prep would be harder to come up with the non-recursive version.unknown|1 year ago
[deleted]
mirekrusin|1 year ago
jerf|1 year ago
In a pure ASCII world, this doubles as "how do you reverse a string". In a Unicode world, the answer to "how do you reverse a string" is "you should never want to do that".
ryanmcbride|1 year ago
pino999|1 year ago
If you see a binary tree T e as some kind of function, it can test whether an element exists, a typical set operation. So f : e -> {0,1}, where (e,1) means the element is in the binary tree. (e,0) means it is not in the binary tree. All those (e,0) creates some sort of complement tree, which might also be seen as inverting it.
What would be really weird is seeing it as a directed acyclic graph and invert the direction of every edge.