Interview Q&A / Aptitude

AdvancedQuick answer1 min readUpdated 3 Oct 2026

In how many ways can 5 boys and 3 girls stand in a row so that no two girls are next to each other?

SHORT ANSWER

14,400. Arrange the boys first: 5! = 120. They create 6 gaps (including the two ends). Choose and fill 3 of those gaps with the girls in order: 6 x 5 x 4 = 120. Total 120 x 120 = 14,400.

Explain it simply

To keep certain people apart, seat the others first and then place the "keep apart" people in the gaps between them, like spacing out the strongest batters in a batting order. With 5 boys in a row there are 6 gaps: one before each boy and one at the end. Putting at most one girl per gap guarantees no two girls touch.

Example

Question: 5 boys, 3 girls in a row, no two girls adjacent.

  1. Arrange boys: 5! = 120.
  2. Gaps: B B B B B = 6 gaps.
  3. Place 3 distinct girls in 3 of the 6 gaps: P(6, 3) = 6 x 5 x 4 = 120.
  4. Total = 120 x 120 = 14,400.

Contrast: all 3 girls together would be 6! x 3! = 720 x 6 = 4,320. "No two together" is stricter than "not all together", which would be 8! - 4,320 = 40,320 - 4,320 = 36,000.

js
const f = n => (n <= 1 ? 1 : n * f(n - 1));
console.log(f(5) * 6 * 5 * 4); // Output: 14400
console.log(f(8) - f(6) * f(3)); // Output: 36000

What to say in the interview

"I seat the 5 boys first, 120 ways, which leaves 6 gaps. Putting the 3 girls into different gaps is 6 times 5 times 4, which is 120. So 14,400 arrangements."

Common mistakes

  • Using 4 gaps (only between boys) and forgetting the two ends.
  • Confusing 'no two together' with 'not all three together'.

#aptitude#permutations-combinations#gap-method

Related questions

Practise more Aptitude questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Aptitude quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.