Fill given box

Need help on this problem:

I know it can be done using backtracking,but I am not able to frame the solution.
If possible for anyone please share your approach and code.
It is a Samsung Interview question.

Please help at the earliest.
Thanks!!

1 Like