leetcode 872. Leaf-Similar Trees

題目大意就是判斷兩棵樹的葉子序列是否一樣,要考慮順序。樣例: For example, in the given tree above, the leaf value sequence is (6, 7, 4, 9, 8). 思路: 別想複雜了,就是求出每棵樹的葉子序列,然後比較就可以了。 求葉子序列我用的是 中序遍歷。 AC代碼: /** * Definition for a binary t
相關文章
相關標籤/搜索