Leetcode 314 Binary Tree Vertical Order Traversa

This question is nothing fancy, just need to get the position that the root should be. and the length for the whole array


The idea is from here.

http://www.shuatiblog.com/blog/2014/12/17/Print-Binary-Tree-Vertically/

and use these two sentence to get the root position and the length of the array.

    int rootIndex = 0 - range[0];
    int columns = range[1] - range[0] + 1;


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章