comments about how to solve the problem

general case
special case