Juspay Tree of Space Hackathon Part B Thread Safe

juspay logo
juspay
May 24, 20257 reads

Summary

I was interviewed by Juspay and asked to design a thread-safe locking system for a tree. I discussed multiple approaches and provided a detailed custom Spinlock implementation, addressing the interviewer's requirement for a library-free solution.

Full Experience

I was presented with the following problem:

Design a thread-safe locking system for a tree. Each node can be locked by a user only if: None of its ancestors or descendants are locked. Locking/Unlocking must be thread-safe (no race conditions). The solution should efficiently support concurrent operations.

The interviewer shared my Hackathon Part A solution that I had submitted previously. They were specifically looking for a solution without using any libraries and wanted me to break down the algorithm and make it thread-safe. My advice for this round is to just stay calm and communicate clearly. That’s all you can do.

Interview Questions (1)

Q1
Design Thread-Safe Tree Locking System
Data Structures & AlgorithmsHard

Design a thread-safe locking system for a tree. Each node can be locked by a user only if: None of its ancestors or descendants are locked. Locking/Unlocking must be thread-safe (no race conditions). The solution should efficiently support concurrent operations.

Discussion (0)

Share your thoughts and ask questions

Join the Discussion

Sign in with Google to share your thoughts and ask questions

No comments yet

Be the first to share your thoughts and start the discussion!