2 ms·
Most people interpreted it as a horizontal flip like you did, though some cursed souls leapt to doing a vertical flip and converting it into a DAG. A horizontal
by recursivecaveat 6y ago
Most people interpreted it as a horizontal flip like you did, though some cursed souls leapt to doing a vertical flip and converting it into a DAG. A horizontal flip is actually extremely simple, just check the base case, swap the pointers and recurse. Arguably easier than fizzbuzz, and imo a pretty solid interview question. A good argument for physically flipping it instead of tagging it as flipped is that localizes the operation instead of leaking a (potentially recursively) tagged tree into the rest of the application. Of course all the ink spilled about binary tree 'inversion' doesn't have much to do with the actual interview, which apparently was actually about converting from a min-heap to max-heap. Max also self-described as 'rude' w/r/t the interview, so hard to know if the heap incident was even why he wasn't selected.