Recently I came across a question in which we had to find the no. of ways to distribute N balls into 3 boxes such that the number of box getting maximum no. of balls is exactly 1.
For example
if N=2, ans is 2 : {2,0,0},{0,2,0},{0,0,2}
if N=3, ans is 9 : {3,0,0},{0,3,0},{0,0,3},{3,2,1},{3,1,2},{1,3,2},{2,3,1},{1,2,3},{2,1,3}
Now, since the number of boxes here is only 3, I was able to solve the question by observation and basic maths(Arith. Prog.) My query is how to solve the above question if the number of boxes is K?