Code RoomConflict seating tables
EasyPrep Room Coding #4763

Conflict seating tables

CodingAlgorithms & data structuresEntry–Mid~16 min

An event planner seats a guest list at identical tables. guest_names lists everyone, and conflicts holds pairs written as "ana|bo", meaning those two must never share a table. A table holds at most table_seats guests and the hall supplies as many tables as the planner asks for. Return the smallest number of tables that seats everyone while keeping every conflicting pair apart. A pair may be listed more than once and may appear in either order, and both names always come from guest_names. table_seats is at least 1, so seating each guest alone always works and gives an upper bound. An empty guest list needs no tables, so return 0. There are at most 8 guests.

Implement
fewest_banquet_tables(guest_names: list[str], conflicts: list[str], table_seats: int) → int
Examples
in[["ana","bo","cy","dee"],["ana|bo","cy|dee"],2]out2
in[["ana","bo","cy"],["ana|bo","bo|cy","ana|cy"],4]out3
in[["ana","bo","cy","dee"],[],1]out4
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 16 min
InputExpectedGot
[["ana","bo","cy","dee"],["ana|bo","cy|dee"],2]2not run yetsample
[["ana","bo","cy"],["ana|bo","bo|cy","ana|cy"],4]3not run yetsample
[["ana","bo","cy","dee"],[],1]4not run yetsample