Sherlock And Beast Hackerrank Solution