LeetCode 1448. Count Good Nodes in Binary Tree
·
코딩테스트/LeetCode
1448. Count Good Nodes in Binary TreeProblemSolutionThe requirements of this problems are as follows:A node is called good if its value is the largest on the path from the root to that node.Return the number of good nodes.To satifsy these requirments, I used a preorder traversal with a stack. First, initialize stack as a list containing root and root.val and set good as 0.Each element in the sta..