Free beta: free to use with daily limits while we build. Join the waitlist for founding-member pricing at launch. Join the waitlist

Sign up free

Palantir interview question

Build a session manager that keeps session counts balanced across servers

Company:
Palantir
Type:
Coding
Difficulty:
Easy
Reported:
October 19, 2026

Problem

Implement a session manager for a fixed set of servers.

  • The manager is created with a list of server names.
  • start_session() creates a new session, gives it a session ID that has never been used before, assigns it to one of the servers and returns the ID.
  • get_allocation() returns the current allocation: for every server, the IDs of the sessions assigned to it.

At all times, the numbers of sessions on any two servers must differ by at most one. The format of the IDs is up to you as long as they are unique, and when several servers are equally good choices, any of them may receive the new session. Write your own tests for the class as part of the answer.

Example 1

Input:  SessionManager(["A", "B", "C"])
        start_session()  (four times, returning s1, s2, s3, s4)
        get_allocation()
Output: one valid allocation: {"A": [s1, s4], "B": [s2], "C": [s3]}

After four sessions on three servers the counts must be 2, 1 and 1 in some order; which server receives the extra session is free.

Example 2

Input:  SessionManager(["solo"])
        start_session()  (twice, returning s1, s2)
        get_allocation()
Output: {"solo": [s1, s2]}

With a single server, every session goes to it.

Constraints

  • The server list is fixed when the manager is created; how to handle an empty list is your choice (the reference solution rejects it).
  • Session IDs are never reused.
  • After every call, the largest and smallest per-server session counts differ by at most one.

Reported by candidates or drawn from publicly available sources, and rewritten in our own words. Pathwise Prep does not publish confidential assessment content. Report a concern