class SessionManager:
Part 1 — Session Manager
Reported once: the coding half of a one-hour first-round phone screen. You are given a template class to implement: a session manager with two functions.
start_session(session_id: str) -> None starts a new session on one of the servers. A session id that has already started must not be added again.get_allocation() -> Dict[str, Set[str]] returns each server mapped to the set of session ids it holds.Sessions must stay balanced. The report's example has three servers, [s1, s2, s3]: at all times no server's session count may differ from any other server's by more than 1, so [8, 8, 8] and [8, 8, 7] are fine.
At the end you write your own test cases; the report says a few normal cases and edge cases were enough.
What the tests call. SessionManager(servers), then start_session(session_id) and get_allocation(). Our setup — ask your interviewer: the class name SessionManager and a constructor that takes the list of server ids (the report doesn't say how the servers are given; a constructor with no argument that uses s1, s2, s3 also passes). The tests check that counts never differ by more than 1, that every started id sits on exactly one server, and that a repeated id is not added again (ignoring it or raising both pass). They do not check server names, tie-breaks, or which server gets a given session.
One report: a first-round phone screen posted in May 2026. The poster was contacted by a recruiter on LinkedIn and believed the track was backend. The hour was about 15 minutes of resume deep-dive (pick a project; the follow-ups were mostly about method and how you made decisions, not technical), then about 40 minutes of coding from a template class. The poster wrote their own tests at the end and says roughly testing normal cases and edge cases was enough. No outcome is stated; the poster felt it went fairly well.
Beyond the report (our practice, not asked in any report): ending a session can break the balance on its own ([3, 3, 3] to [1, 3, 3]); a repeated id submitted from two threads at once needs the check and the add under one lock; and returning copies from get_allocation stops a caller from changing your state.
Part 1 — Session Manager
Reported once: the coding half of a one-hour first-round phone screen. You are given a template class to implement: a session manager with two functions.
start_session(session_id: str) -> None starts a new session on one of the servers. A session id that has already started must not be added again.get_allocation() -> Dict[str, Set[str]] returns each server mapped to the set of session ids it holds.Sessions must stay balanced. The report's example has three servers, [s1, s2, s3]: at all times no server's session count may differ from any other server's by more than 1, so [8, 8, 8] and [8, 8, 7] are fine.
At the end you write your own test cases; the report says a few normal cases and edge cases were enough.
What the tests call. SessionManager(servers), then start_session(session_id) and get_allocation(). Our setup — ask your interviewer: the class name SessionManager and a constructor that takes the list of server ids (the report doesn't say how the servers are given; a constructor with no argument that uses s1, s2, s3 also passes). The tests check that counts never differ by more than 1, that every started id sits on exactly one server, and that a repeated id is not added again (ignoring it or raising both pass). They do not check server names, tie-breaks, or which server gets a given session.
| Approach | Notes |
|---|---|
| Round robin | our analysis: also meets the reported balance rule while sessions are only added; the min-heap is the reported approach |
| Linear min() over the counts | our analysis: O(servers) per insert instead of O(log servers); with three servers it is equally fine |
Edge cases probed: A repeated session id: an id that has already started must not be added again (the one edge case the report names; it doesn't say whether to ignore it or raise)
If you have had this round, tell us how close this page was. It is how we keep the pages accurate.
Send them this page. It is free to read, no account needed.
What you just read — canonical solution, follow-up arc, what passing candidates actually did — exists for all 11 Palantir questions, refreshed monthly from new candidate reports.