Doubt in Problem CROWD

Problem: CROWD

Editorial: CROWD Editorial

I just wanted to ask that if there are 5 houses in a row, how are there 8 ways so select conflicting houses? (The answer according to the code given in the editorial).

According to me, conflicting sets of houses would be: {1,2,3} {2,3,4} {3,4,5} {1,2,3,4} {2,3,4,5} {1,2,3,4,5} (6 sets) which would have conflicts.

I solved the problem using the formula: Summation and I can’t understand what’s wrong with this approach!

Any help would be appreciated! Thanks in advance!

The problem is that you’re ignoring cases like {1, 2, 3, 5} and {1, 3, 4, 5} i.e. only 3 houses need not be consecutive, there can be other ways to choose from rest of the houses.

1 Like
//