HACKERRANK: Manasa and Stones

https://www.hackerrank.com/challenges/manasa-and-stones