Skip to content

Commit cc89642

Browse files
authored
Update construct-binary-tree-from-preorder-and-postorder-traversal.cpp
1 parent 86c5314 commit cc89642

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

C++/construct-binary-tree-from-preorder-and-postorder-traversal.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class Solution2 {
5252
return nullptr;
5353
}
5454
auto node = new TreeNode(pre[pre_s]);
55-
if (pre_s + 1 < pre_e) {
55+
if (pre_e - pre_s > 1) {
5656
auto left_tree_size = post_entry_idx_map.at(pre[pre_s + 1]) - post_s + 1;
5757
node->left = constructFromPrePostHelper(pre, pre_s + 1, pre_s + 1 + left_tree_size,
5858
post, post_s, post_s + left_tree_size,

0 commit comments

Comments
 (0)