Holiday accomodation

every person wants to explore the world so every prson will go to every city or we have to sent them only to one another city

hello @deepakjumani09

no not every city , a person can choose only one city as its destination city.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

for 4 persons in bruteforce bhaiya said that there are n! possibilities but there are only few possibilities (1,2)&3,4 1,3&2,4 1,4&2,3 how n! possibilities

optimal answer will be less but to find these optimal answer brute force approach will try all possible configuration because of which time complexity will be n!.

same case when 4 person are there. brute force will try all possibel permuation of (1,2,3,4) and consider only most optimal one.

@deepakjumani09
I see you have reopened this doubt
How can I help you ?

for 4 persons in bruteforce bhaiya said that there are n! possibilities but there are only few possibilities (1,2)&3,4 1,3&2,4 1,4&2,3 how n! possibilities

@deepakjumani09
We are not exchanging houses between pairs of people
Any person can go to any house
So if there are 4 houses
4 people can go to first
3 can go to second
and so on
This is permutation

but in the first line of the question says that we are exchanging houses

and also while explaining the test case bhaiya exchanged in pair

@deepakjumani09
He might have used example that way
But houses are not necessarily exchanged in pair
Hence n!