Preorder Traversal Without Invalid Nodes
Examples
Example 1:
Input: n = 7, edges = [[0,1],[0,2],[1,3],[1,4],[2,5],[2,6]], root = 0, invalid = [1,6]
Output: [0,3,4,2,5]
Explanation:
Example 2:
Input: n = 5, edges = [[0,1],[0,2],[1,3],[1,4]], root = 0, invalid = [0,4]
Output: [1,3,2]
Explanation: