Node sharing question Uber
Summary
I was asked a challenging node-sharing system design question during my Uber interview for a Senior position in San Francisco, involving the implementation of hardware request and release functions.
Full Experience
During my interview for a Senior position at Uber in San Francisco, I encountered a practical problem related to managing nodes within a server cluster. The core task involved designing and implementing two primary functions: one to request_hardware and another to release_hardware. I had to consider different node types (T1, T2, T3), ensuring each node was unique and tied to its specific type. The problem specified constraints such as handling zero available nodes and preventing the release of an already free node. A crucial part of the discussion also involved analyzing the time and space complexity of my chosen data structures and algorithm.
Interview Questions (1)
In a server cluster, there are three different types of nodes, denoted by T1, T2, T3. Each node is unique and limited to one fixed type. The minimum quantity of nodes that can exist in the cluster for each type (T1, T2, T3) is 0 (zero), with no upper limit on availability. Implement the following functions:
1. request_hardware function:
- Given a valid requested node type, it looks up the collection of available nodes of that type.
- Returns one available node of the requested type and sets its state to 'in use'.
- If there are zero or no available nodes of the requested type, it cannot be requested.
2.
release_hardware function:- Given a valid node whose state is 'in use', it releases the node back to the server cluster.
- Sets the state of the released node as 'free'.
- If the given node is already set to a state of 'free', it cannot be released.
Ending question: What is the time/space complexity of the data structure/algorithm?