
Do you need help with
和preorder那题相似,只是从后往前遍历的。还是用inorder来的到左边和右边的size,用postorder来的到root public TreeNode build(int[] inorder, int[] postorder, int inStart, int inEnd, int post, HashMap<Integer, Integer> map){ int index = map.get(postorder[post]); int leftSize = index - inStart; int rightSize = inEnd - index; int left = post - rightSize -1; int right = post - 1; TreeNode root = new TreeNode(postorder[post]); if(leftSize > 0) { root.left = build(inorder, postorder, inStart, index-1, left, map); } if(rightSize > 0) { root.right = build(inorder, postorder, index+1, inEnd, right, map); } return root; }
Then try StudyFetch, the AI-powered platform that can answer your questions and teach you more about it!


How StudyFetch Helps You Master This Topic
AI-Powered Explanations
Get in-depth, personalized explanations on this topic and related concepts, tailored to your learning style.
Practice Tests
Take adaptive quizzes that focus on your weak areas and help reinforce your understanding of the subject.
Interactive Flashcards
Review key concepts and terms with AI-generated flashcards, optimizing your retention and recall.
Educational Games
Engage with fun, interactive games that reinforce your learning and make studying more enjoyable.
Start mastering this topic and many others with StudyFetch's comprehensive learning tools.