Sherlock And Cost Hackerrank Solution Java