Leetcode 1766. Tree of Coprimes
Given a rooted tree with a value on each node, for every node return the nearest ancestor whose value is coprime with the node's value (or -1 if none). The challenge is to traverse the tree while efficiently tracking the most recent ancestor indices for each possible value (nums[i] ≤ 50) so you can quickly find the closest coprime ancestor.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
0
Hello Interview Premium
Your account is free and you can post anonymously if you choose.