Mark and Toys

The following is solution to hacker rank problem Mark and Toys