As a graduate I went for an interview for a java development role and was doing pretty well in the technical examinations until i came up against this question.
If i
Probably get started on looking at Dynamic programming. However you could any approach problem for that matter trivially. How would you do that manually ??. Jot down the steps. Convert it into an algorithm yourself. Probably studying Permutations & Combinations would help for better understanding of the problem you have stated.
Hope it helps.