Tesla Interview Question

Writing the code to implement the collision detection