Tesla Interview Question

it was completing based on coding (coder pad)