Hackerrank Save Humanity problem