Seating arrangement of N boys sitting around a round table such that two particular boys sit together
There are N boys which are to be seated around a round table. The task is to find the number of ways in which N boys can sit around a round table such that two particular boys sit together.
Input: N = 5
2 boy can be arranged in 2! ways and other boys
can be arranged in (5 – 1)! (1 is subtracted because the
previously selected two boys will be considered as a single boy now)
So, total ways are 2! * 4! = 48.
Input: N = 9
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.
- First, 2 boys can be arranged in 2! ways.
- No. of ways to arrange remaining boys and the previous two boy pair is (n – 1)!.
- So, Total ways = 2! * (n – 1)!.
Below is the implementation of the above approach: