PRoblem from hackerrank