Available question text
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.
Related questions
Continue with questions that share topics or the same question type.
- Binary Tree Preorder Traversal
Coding · Binary Tree · Depth-First Search · Stack
- Construct Binary Search Tree from Preorder Traversal
Coding
- Construct Binary Tree from Preorder and Inorder Traversal
Coding
- Construct Binary Tree from Preorder and Postorder Traversal
Coding
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 971. Flip Binary Tree To Match Preorder Traversal
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source