6 distinct balls , 3 distinct boxes // condition : each box must be non-empty
part 1) total ways to distribute 6 distinct balls to 3 distinct boxes , when there is no condition
every ball has 3 homes and there are 6 such balls so it's 3*3*3*3*3*3=36
Out of these 36 ways we have to subtract ways when there is exactly one box is empty ans when there is exactly 2 boxes are empty.
Part 2 ) case 1 : # ways when exactly 2 boxes are empty : select 2 boxes out of 3 (3C2)and then put 6 balls in one box(16)
total = 3C2*16=3 ways
Part 2 ) case 2 : # ways when exactly 1 box is empty :-select one box out of 3 (3C1 ways) put 6 balls into 2 boxes such that no box remain empty (let consider this x)
now we have to find 'x' , follow same step total ways - when exactly one empty = 26-(2C1)*16=62 ways
put the value of x so # ways when exactly 1 box is empty =(3C1)*62=186
so total ways when no box would be left empty = (part 1)- (part 2 case 1)-(part 2 case 2)
36-3-186=729-189=540 ways