[leetcode 872] Leaf-Similar Trees – hwchang0417
給定兩棵樹,判斷它們由左到右的所有葉節點數字一不一樣。
If all leave node of two trees from left to right are the same, return true.
Programming Language: C++
Execution time: 0 ms
Solution:
首先,對兩棵樹進行走訪,將各自的葉節點從左到右放入陣列內,再來依序以陣列的大小、陣列內的元素進行比較。
At first, we traverse two trees in order from left to right. To store every leave node of two trees into two vector. Then we compare array size and elements of two vector.
Read full article from [leetcode 872] Leaf-Similar Trees – hwchang0417
No comments:
Post a Comment