QuestionGiven therootof a binary tree, returnthe vertical order traversalof its nodes' values. (i.e., from top to bottom, column by column).If two nodes are in the same row and column, the order should be fromleft to right.Example:Input: root = [3,9,8,4,0,1,7]
Output: [[4],[9],[3,0,1],[8],[7]]AlgorithmThis question, I did it 10 days ago with error.And today I did it with one pass and is the standard answer. Interesting.Basically we traverse all the node and keep its column number at the same time. The logic is left child is root's column number minus one and right child column number is root
...
继续阅读
(36)