Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Search
⌘K
Get Premium
Leetcode 971. Flip Binary Tree To Match Preorder Traversal
Given a binary tree and a target preorder sequence voyage, find the minimum set of nodes to flip (swap their left and right children) so the tree's preorder equals voyage, or return [-1] if impossible. Algorithmically, simulate a preorder traversal and greedily flip a node when its left child's value doesn't match the next voyage value, recording flipped nodes.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.