当前位置:网站首页>889. construct binary tree according to preorder and postorder traversal

889. construct binary tree according to preorder and postorder traversal

2022-06-11 02:22:00 Melody2050

Blog explanation https://grandyang.com/leetcode/889/

The time complexity of a normal recursive approach is O(n^2), But at the end of the paper, we give the stack implementation O(n) Time complexity solution . But the answer is stuck to leetcode There will be a mistake .

Optimization of recursive approach , Can be introduced hashmap The nodes -> Index save , Appropriately speed up the search .

原网站

版权声明
本文为[Melody2050]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206110107140638.html