sherlock and cost hackerrank solution