Roads And Libraries Hackerrank Solution Java