Tesla interview question

Writing the code to implement the collision detection