hachyderm.io is one of the many independent Mastodon servers you can use to participate in the fediverse.
Hachyderm is a safe space, LGBTQIA+ and BLM, primarily comprised of tech industry professionals world wide. Note that many non-user account types have restrictions - please see our About page.

Administered by:

Server stats:

9.4K
active users

Šimon Tóth

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: compiler-explorer.com/z/o5Gee9
Solution: compiler-explorer.com/z/e9GKaK