Home Interview Seating Arrangement Problems Explained — Formulas, Tricks & Solved Examples

Seating Arrangement Problems Explained — Formulas, Tricks & Solved Examples

In Plain English 🔥
Imagine you're organising a birthday party and need to figure out how many different ways 6 friends can sit around a round table — especially when two of them had a fight and can't be next to each other. That's a seating arrangement problem. It's just counting the number of valid ways people (or objects) can be placed in seats, given a set of rules. Once you see it that way, the maths feels a lot less scary.
⚡ Quick Answer
Imagine you're organising a birthday party and need to figure out how many different ways 6 friends can sit around a round table — especially when two of them had a fight and can't be next to each other. That's a seating arrangement problem. It's just counting the number of valid ways people (or objects) can be placed in seats, given a set of rules. Once you see it that way, the maths feels a lot less scary.

Seating arrangement problems show up everywhere — from airline seat allocation algorithms and exam hall planning tools to the classic 'how many ways can a board of directors be seated for a photo?' The reason they're so common in aptitude tests and technical interviews is that they test whether you can break a complex constraint problem into smaller, countable parts. It's not about memorising formulas; it's about building a mental model of the problem space.

The core challenge these problems solve is this: given N people and a set of constraints (must sit together, must not sit adjacent, one person must always face a particular direction), how do you count all valid arrangements without listing every single one manually? The answer lives at the intersection of permutations, combinatorics, and a handful of elegant tricks that make hard problems tractable in seconds.

By the end of this article you'll be able to confidently tackle linear and circular seating problems, handle 'always together' and 'never together' constraints using the bundle and complement techniques, apply the correct formula instantly without second-guessing yourself, and walk into an interview knowing exactly why the circular arrangement formula loses a factor of N compared to the linear one.

Linear vs Circular Seating — Why the Formula Changes

In a linear arrangement, seats have fixed identities: seat 1, seat 2, seat 3. Swapping everyone one position to the right creates a genuinely different arrangement because position 1 is now empty and position N has a new occupant. So N people in a row = N! arrangements. Simple.

In a circular arrangement, there are no fixed reference points. If everyone shifts one seat clockwise, it looks identical — same neighbours, same relative order. To remove these duplicate rotations, we fix one person in place and arrange the remaining N−1 people around them. That gives (N−1)! arrangements.

This is the single most important conceptual leap in seating problems. The formula doesn't change because circular maths is harder — it changes because 'different' means something different. Two arrangements are the same if one is a rotation of the other, so we divide out the N rotational duplicates, leaving (N−1)!.

For a necklace or a round table where flipping is also considered the same (like identical chairs with no head), you divide again by 2, giving (N−1)!/2. But in most interview problems the seats are distinguishable by facing direction, so (N−1)! is your default circular formula.

SeatingArrangementBasics.py · PYTHON
12345678910111213141516171819202122232425262728293031323334353637383940414243
import math

def linear_arrangements(total_people):
    """
    Count arrangements of 'total_people' in a straight row.
    Every position is unique, so full permutation applies.
    """
    return math.factorial(total_people)

def circular_arrangements(total_people):
    """
    Count arrangements around a round table.
    We fix one person to eliminate rotational duplicates,
    then arrange the remaining (total_people - 1) freely.
    """
    if total_people < 1:
        return 0
    return math.factorial(total_people - 1)

def circular_necklace_arrangements(total_people):
    """
    For a necklace / identical chairs where flipping = same arrangement.
    Divide circular count by 2 to eliminate mirror duplicates.
    """
    if total_people < 1:
        return 0
    return math.factorial(total_people - 1) // 2

# --- Demo ---
people = 6

print(f"People: {people}")
print(f"Linear (straight row):          {linear_arrangements(people):>6}")
print(f"Circular (round table):         {circular_arrangements(people):>6}")
print(f"Necklace (flip = same):         {circular_necklace_arrangements(people):>6}")

# Step-by-step breakdown to show the maths
print("\n--- Why the numbers differ ---")
print(f"Linear  = {people}!  = {math.factorial(people)}")
print(f"Circular = ({people}-1)! = {people-1}! = {math.factorial(people-1)}")
print(f"Necklace = ({people}-1)!/2 = {math.factorial(people-1)//2}")
print(f"\nRatio Linear/Circular = {linear_arrangements(people)//circular_arrangements(people)}")
print(f"That ratio equals N ({people}) — exactly the rotational duplicates we removed.")
▶ Output
People: 6
Linear (straight row): 720
Circular (round table): 120
Necklace (flip = same): 60

--- Why the numbers differ ---
Linear = 6! = 720
Circular = (6-1)! = 5! = 120
Necklace = (6-1)!/2 = 60

Ratio Linear/Circular = 6
That ratio equals N (6) — exactly the rotational duplicates we removed.
🔥
The One Ratio Worth Memorising:Linear arrangements are always exactly N times more than circular arrangements for the same N people. If you ever get a circular answer that's larger than linear/N, something's wrong.

The Bundle Trick — Solving 'Must Sit Together' Constraints

When two or more people must always sit next to each other, you stop thinking of them as individuals and treat them as a single super-person. This is the bundle trick (also called the grouping method).

Here's the reasoning: if Alice and Bob must be adjacent, tape them together. Now you have one bundle + the remaining people. Arrange that new, smaller group first — that gives you the arrangements of the bundle among everyone else. Then, inside the bundle, Alice and Bob can swap with each other (2! = 2 ways). Multiply the two counts together.

For a circular table with N people where K of them must always sit together: form one bundle of K people. You now have (N − K + 1) units to arrange around the table = (N − K)! ways. Internally, the bundle can be arranged in K! ways. Total = (N − K)! × K!.

The trick generalises cleanly. Three people who must all sit together? Bundle of 3, internal arrangements = 3! = 6. The formula doesn't change shape — just the numbers inside it. This is why understanding the reasoning beats memorising a list of formulas.

BundleTrickSeating.py · PYTHON
12345678910111213141516171819202122232425262728293031323334353637
import math

def circular_with_bundle(total_people, bundle_size):
    """
    Round-table arrangements where 'bundle_size' specific people
    must ALWAYS sit together.

    Step 1: Treat the bundle as one unit.
            Total units = total_people - bundle_size + 1
    Step 2: Circular arrangements of those units = (units - 1)!
    Step 3: Internal arrangements of the bundle = bundle_size!
    Step 4: Multiply Step 2 × Step 3
    """
    units = total_people - bundle_size + 1   # bundle counts as 1 seat
    circular_of_units = math.factorial(units - 1)  # fix one unit, arrange rest
    internal_bundle   = math.factorial(bundle_size) # bundle members swap freely

    total = circular_of_units * internal_bundle
    return total, circular_of_units, internal_bundle, units

# --- Problem: 6 people around a round table; Alice, Bob and Carol MUST sit together ---
total   = 6
bundle  = 3  # Alice, Bob, Carol

total_ways, circ, internal, units = circular_with_bundle(total, bundle)

print(f"Total people : {total}")
print(f"Bundle size  : {bundle} (must sit together)")
print(f"Units to arrange around table : {units}  (bundle + {total - bundle} individuals)")
print(f"\nCircular arrangements of {units} units : ({units}-1)! = {units-1}! = {circ}")
print(f"Internal arrangements of bundle       : {bundle}! = {internal}")
print(f"\nTotal valid arrangements : {circ} × {internal} = {total_ways}")

# --- Compare: no restriction baseline ---
baseline = math.factorial(total - 1)
print(f"\nBaseline (no restriction)              : {baseline}")
print(f"Restriction reduces count by factor    : {baseline / total_ways:.2f}x")
▶ Output
Total people : 6
Bundle size : 3 (must sit together)
Units to arrange around table : 4 (bundle + 3 individuals)

Circular arrangements of 4 units : (4-1)! = 3! = 6
Internal arrangements of bundle : 3! = 6

Total valid arrangements : 6 × 6 = 36

Baseline (no restriction) : 120
Restriction reduces count by factor : 3.33x
⚠️
Pro Tip — Bundles Inside Bundles:If a problem says 'A and B must sit together AND C and D must sit together', create two separate bundles. You'll have (N − 4 + 2) = N−2 units to arrange. Each bundle has its own 2! internal factor. Multiply all three counts: circular × 2! × 2!.

The Complement Method — Solving 'Must NOT Sit Together' Constraints

Counting what you don't want directly is usually harder than counting everything, then subtracting the bad cases. That's the complement method, and it's your best friend for 'must never sit adjacent' constraints.

The formula is: Valid arrangements = Total arrangements − Arrangements where the restricted pair ARE together.

Why does this work so cleanly? Because the bundle trick already gives you a precise count of arrangements where a specific group IS together. So you're doing: All − (Bundle count) = Never-together count.

The complement method also generalises to multiple pairs who can't sit together, but you need inclusion-exclusion for that: subtract each bad pair, add back cases where two pairs are both bad (because you subtracted those twice), and so on. For interviews, you'll almost never need beyond two restricted pairs, so the two-step version covers 95% of problems.

One nuance: for a circular arrangement, 'adjacent' means both left-adjacent AND right-adjacent. The bundle trick inherently covers both directions because placing two people in a bundle allows them to appear as AB or BA (the internal 2! factor). So no extra adjustment is needed.

ComplementMethodSeating.py · PYTHON
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
import math

def circular_never_together(total_people, restricted_pair_count=1):
    """
    Round-table arrangements where one specific PAIR must NEVER sit together.

    Complement approach:
      Total circular arrangements
      MINUS arrangements where the pair IS together (bundle trick)
    """
    # Total: fix one person, arrange the rest
    total_circular = math.factorial(total_people - 1)

    # Bad cases: treat the pair as one bundle
    # units = total_people - 2 + 1 = total_people - 1
    units_with_bundle     = total_people - 2 + 1
    bundle_circular       = math.factorial(units_with_bundle - 1)  # circular of units
    bundle_internal       = math.factorial(2)                       # pair can swap: AB or BA
    arrangements_together = bundle_circular * bundle_internal

    valid = total_circular - arrangements_together
    return total_circular, arrangements_together, valid

# --- Problem: 5 people at a round table; Dave and Eve must NEVER be adjacent ---
total = 5

total_circ, together, valid = circular_never_together(total)

print(f"Total people : {total}")
print(f"\nStep 1 — Total circular arrangements : ({total}-1)! = {total-1}! = {total_circ}")
print(f"Step 2 — Arrangements where the pair")
print(f"         IS together (bundle method)  : {together}")
print(f"Step 3 — Valid (pair never adjacent)  : {total_circ} - {together} = {valid}")

# --- Verification by brute force for small N ---
from itertools import permutations

people = ['A', 'B', 'C', 'D', 'E']  # D and E are the restricted pair
restricted = {'D', 'E'}

def are_adjacent_circular(arrangement, p1, p2):
    """Check if p1 and p2 sit next to each other in a circular layout."""
    n   = len(arrangement)
    idx1 = arrangement.index(p1)
    idx2 = arrangement.index(p2)
    # In a circle, neighbours of seat i are (i-1)%n and (i+1)%n
    return abs(idx1 - idx2) == 1 or abs(idx1 - idx2) == n - 1

# Fix 'A' in position 0 to eliminate rotational duplicates
fixed_arrangements = [
    ('A',) + perm
    for perm in permutations(['B', 'C', 'D', 'E'])
]

valid_brute = [
    arr for arr in fixed_arrangements
    if not are_adjacent_circular(list(arr), 'D', 'E')
]

print(f"\nBrute-force verification            : {len(valid_brute)} valid arrangements")
print(f"Formula matches brute force         : {valid == len(valid_brute)}")
▶ Output
Total people : 5

Step 1 — Total circular arrangements : (5-1)! = 4! = 24
Step 2 — Arrangements where the pair
IS together (bundle method) : 12
Step 3 — Valid (pair never adjacent) : 24 - 12 = 12

Brute-force verification : 12 valid arrangements
Formula matches brute force : True
⚠️
Watch Out — Inclusion-Exclusion for Multiple Restricted Pairs:If TWO separate pairs (A,B) and (C,D) must never sit together, you can't just subtract both bundle counts independently. You'd double-subtract the cases where BOTH pairs happen to be together. Use: Valid = Total − |A∩B together| − |C∩D together| + |both pairs together|.

Worked Exam Problems — Putting It All Together

Let's solve three problems that show up repeatedly in placement exams and technical interviews. Each one layers a new constraint on top of the previous one, so you can see how the techniques stack.

Problem 1 is the pure baseline: no constraints, just count the arrangements. Problem 2 adds a 'must sit together' constraint using the bundle trick. Problem 3 uses the complement method for a 'must not sit together' scenario.

The code below solves all three with clear, step-by-step output so you can follow the reasoning as well as verify the numbers. Notice how the solution structure is identical each time — only the numbers going into the formula change. That's the signal that you've understood the underlying pattern, not just the specific problem.

One thing worth noting: always state your assumptions about what 'different arrangement' means in a circular context before you start. Interviewers sometimes deliberately leave this ambiguous to see if you ask clarifying questions. That alone distinguishes strong candidates.

ExamProblemsSolved.py · PYTHON
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
import math

print("=" * 55)
print("PROBLEM 1: 7 people, round table, no restrictions")
print("=" * 55)
total_people = 7
arrangements_p1 = math.factorial(total_people - 1)
print(f"Formula : (N-1)! = ({total_people}-1)! = {total_people-1}! = {arrangements_p1}")

print()
print("=" * 55)
print("PROBLEM 2: 7 people, round table")
print("         Tom and Jerry MUST sit together")
print("=" * 55)
total_people  = 7
bundle_size   = 2  # Tom and Jerry

units         = total_people - bundle_size + 1   # treat bundle as 1 unit => 6 units
circ_units    = math.factorial(units - 1)         # circular arrange 6 units => 5!
internal      = math.factorial(bundle_size)        # Tom-Jerry or Jerry-Tom => 2!
arrangements_p2 = circ_units * internal

print(f"Step 1 : Bundle Tom+Jerry => {units} units to place")
print(f"Step 2 : Circular of {units} units = ({units}-1)! = {units-1}! = {circ_units}")
print(f"Step 3 : Internal bundle arrangements = {bundle_size}! = {internal}")
print(f"Answer : {circ_units} × {internal} = {arrangements_p2}")

print()
print("=" * 55)
print("PROBLEM 3: 7 people, round table")
print("         Tom and Jerry must NEVER sit together")
print("=" * 55)
total_people      = 7

# Total unrestricted circular
total_circular    = math.factorial(total_people - 1)

# Bad cases: Tom+Jerry as bundle
bundle_units      = total_people - 2 + 1           # 6 units
bad_circular      = math.factorial(bundle_units - 1) # 5!
bad_internal      = math.factorial(2)               # 2! = 2
bad_together      = bad_circular * bad_internal

arrangements_p3   = total_circular - bad_together

print(f"Step 1 : Total circular = (7-1)! = 720")
print(f"Step 2 : Together count (bundle) = {bad_circular} × {bad_internal} = {bad_together}")
print(f"Answer : {total_circular} - {bad_together} = {arrangements_p3}")

print()
print("=" * 55)
print("SUMMARY")
print("=" * 55)
print(f"No restriction  : {arrangements_p1}")
print(f"Must together   : {arrangements_p2}")
print(f"Never together  : {arrangements_p3}")
print(f"Sanity check    : 'must' + 'never' + rest should relate to total")
print(f"  Never ({arrangements_p3}) + Together ({arrangements_p2}) = {arrangements_p3 + arrangements_p2} (should = {arrangements_p1})")
▶ Output
=======================================================
PROBLEM 1: 7 people, round table, no restrictions
=======================================================
Formula : (N-1)! = (7-1)! = 6! = 720

=======================================================
PROBLEM 2: 7 people, round table
Tom and Jerry MUST sit together
=======================================================
Step 1 : Bundle Tom+Jerry => 6 units to place
Step 2 : Circular of 6 units = (6-1)! = 5! = 120
Step 3 : Internal bundle arrangements = 2! = 2
Answer : 120 × 2 = 240

=======================================================
PROBLEM 3: 7 people, round table
Tom and Jerry must NEVER sit together
=======================================================
Step 1 : Total circular = (7-1)! = 720
Step 2 : Together count (bundle) = 120 × 2 = 240
Answer : 720 - 240 = 480

=======================================================
SUMMARY
=======================================================
No restriction : 720
Must together : 240
Never together : 480
Sanity check : 'must' + 'never' + rest should relate to total
Never (480) + Together (240) = 720 (should = 720)
🔥
Interview Gold — The Sanity Check:For a two-person restriction, 'always together' + 'never together' must equal the total. If your numbers don't add up, you made an error somewhere. Always run this check in an interview — it shows systematic thinking and catches arithmetic mistakes before they cost you.
AspectLinear ArrangementCircular Arrangement
Base formula (N people, no restriction)N!(N-1)!
Are seat positions unique?Yes — seat 1, seat 2 etc. are distinctNo — only relative positions matter
Rotational duplicates?None — shifting right creates a new arrangementYes — N rotations look identical, so divide by N
Flip (mirror) duplicates?Yes — left-right flip counts as differentOnly removed if stated (necklace): divide by 2
'Must sit together' formula (K bundled)K! × (N-K+1)!/1 (linear of units)K! × (N-K)!
'Never sit together' methodTotal − bundle count for linearTotal − bundle count for circular
Typical exam phrasing'Seated in a row', 'on a bench''Round table', 'circular garden', 'ring'
When to use necklace formulaNever for people problemsOnly when clockwise = anticlockwise (stated explicitly)

🎯 Key Takeaways

  • The circular formula (N-1)! isn't a separate rule — it's N! divided by N rotational duplicates. Understand that and you'll never confuse the two formulas again.
  • The bundle trick converts a 'must sit together' constraint into a smaller, simpler problem: treat the group as one unit, multiply by the group's internal arrangements at the end.
  • The complement method is almost always faster for 'never together' problems: count everything, subtract the cases where the unwanted arrangement occurs (which you can get with the bundle trick).
  • Always run the sanity check: for a two-person restriction, arrangements where they're always together plus arrangements where they're never together must equal the unrestricted total — if it doesn't add up, find the error before moving on.

⚠ Common Mistakes to Avoid

  • Mistake 1: Using N! instead of (N-1)! for circular arrangements — The answer comes out N times too large and won't match any option in a multiple-choice exam — Fix: Always ask yourself 'does rotating everyone one seat give a new arrangement?' If no (round table), use (N-1)!. If yes (seats numbered/labelled), use N!.
  • Mistake 2: Forgetting the internal arrangement factor in the bundle trick — You get the right circular-of-units count but miss multiplying by K!, giving an answer K! times too small — Fix: After counting how the bundles and individuals arrange around the table, always ask 'how many ways can people inside the bundle swap?' Multiply by that K!.
  • Mistake 3: Applying the complement method without checking for double-subtraction — When two different pairs are both restricted from sitting together, subtracting both bundle counts independently over-subtracts cases where both restrictions are violated simultaneously, giving a number that's too low — Fix: Use inclusion-exclusion: Valid = Total − |pair1 together| − |pair2 together| + |both pairs together at once|.

Interview Questions on This Topic

  • QIn how many ways can 8 people be seated around a circular table if two specific people must always sit next to each other? Walk me through your reasoning step by step.
  • QHow many ways can the word ARRANGE be arranged so that the two R's never appear together? (This tests whether you can apply the complement method to non-person seating problems.)
  • QIf 5 boys and 4 girls are to be seated in a row such that no two girls sit adjacent to each other, how do you set up the problem — and why does the order in which you place boys vs girls matter?

Frequently Asked Questions

What is the formula for circular seating arrangements?

For N people seated around a round table where rotations are considered identical, the number of distinct arrangements is (N-1)!. You fix one person in place to eliminate N identical rotations, then freely arrange the remaining N-1 people. If the table also treats clockwise and anticlockwise as the same (like a necklace), divide further by 2 to get (N-1)!/2.

How do you solve seating problems where two people must sit together?

Use the bundle trick: treat the two people as a single unit, reducing the problem from N people to (N-1) units. Count the circular or linear arrangements of those units, then multiply by 2! (the number of ways the two people can swap within their bundle). For K people who must all stay together, the internal factor becomes K! instead of 2!.

When should I use the complement method in seating arrangement problems?

Use the complement method whenever the 'must NOT happen' constraint is harder to count directly than the 'must happen' version. Specifically: when two people must never sit adjacent, count all unrestricted arrangements and subtract the arrangements where they ARE adjacent (which is just the bundle trick answer). The result gives you the valid count without having to enumerate restrictions directly.

🔥
TheCodeForge Editorial Team Verified Author

Written and reviewed by senior developers with real-world experience across enterprise, startup and open-source projects. Every article on TheCodeForge is written to be clear, accurate and genuinely useful — not just SEO filler.

← PreviousLogical Reasoning PatternsNext →Blood Relation Problems
Forged with 🔥 at TheCodeForge.io — Where Developers Are Forged