DEV Community

Cover image for Lockable Tree - Google Interview Question
QuanticDev
QuanticDev

Posted on

Lockable Tree - Google Interview Question

Lockable tree is a great programming interview question asked by Google, and it is a very well thought out one. A lockable tree is a tree with nodes that can be locked if none of the ancestors or descendants is locked. In the question, we are asked to implement locking/unlocking operations that should run in O(h) time where h is the height of the tree.

This is a very well-crafted interview question by Google. Both the requirements and the question itself are quite clear, which is a rarity in the industry. Often, the interviewers will intentionally make the question a little obscure, so they can observe how you do your requirements analysis and if you can communicate with the interviewers clearly. However, in this case, the requirements are clear cut, which I think reflects how Google operates.

I am pretty sure most of the folk here can solve this by themselves. But if you want the full solution with requirements analysis, improvement, and solution steps, here it is: https://quanticdev.com/algorithms/trees/lockable-tree

Top comments (0)