Sherlock And The Beast Hackerrank Solution