Booking.com interview question

Asteroid Collision from leetcode 735