← Questions
Lock, unlock and upgrade nodes in a tree
0
I was asked this
No reports yet. Sign in to say where you were asked it.
A tree is given by a parent array. Implement lock(node, user), unlock(node, user) and upgrade(node, user): a node can be locked by a user if it is unlocked; unlocked only by the user who locked it; and upgraded when it is unlocked, none of its ancestors is locked and at least one descendant is locked, which locks it and unlocks all its descendants. The interviewer gave the problem vaguely, so clarify the rules first.
No official answer yet. Write yours on the right and run it.
Nothing published yet.
Sign in to submit your code; every attempt is kept here.
Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding
