Trains the technique from
LeetCode 2127Maximum Employees to Be Invited to a MeetingThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
Each of n staff, numbered 0 through n - 1, names exactly one other member of staff in pick, and nobody names themselves.
The staff are to be seated round one round table. A member of staff will only sit down if the person they named ends up seated directly beside them, on either side.
Return the largest number of staff that can be seated.
Example 1
Staff 0 and 1 name each other, so they sit side by side. Staff 2 named 1 and staff 3 named 2, so those two line up outwards from the pair and all four are seated.
Example 2
The five name each other round in a ring, so seating them in that order puts everyone beside the person they named.
Example 3
Two separate pairs name each other. Each pair sits together and the two pairs take different stretches of the table, so all four are seated.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def maximum_invitations(pick: list[int]) -> int:public int maximumInvitations(int[] pick)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.