As reported: Goldman Sachs Analyst Superday data structures round with two interviewers (2025): Count Good Nodes in Binary Tree, after Group Anagrams.
A node is good if no node on the path from the root to it has a greater value. Return the number of good nodes.
This is LeetCode 1448 — Count Good Nodes in Binary Tree.
Example 1
root = [3,1,4,3,null,1,5]
-> 4
Example 2
root = [3,3,null,4,2]
-> 3
Example 3
root = [1]
-> 1
Constraints: 1 ≤ nodes ≤ 10^5; -10^4 ≤ Node.val ≤ 10^4.
Code runner format: one JSON value per line: root (LeetCode's test-case format). Implement goodNodes(root); the harness prints the result as JSON.