Tuesday C++ common interview problem: Well-behaved paths in a tree.
Given a tree, represented by two arrays:
- an array of node integer values
- an array of edges as pairs of indexes
Return the number of well-behaved paths:
- begin and end in a node with the same value
- all intermediate nodes have lower or equal values
Solve it yourself: https://compiler-explorer.com/z/o5Gee9v79
Solution: https://compiler-explorer.com/z/e9GKaKbs5