Waymo Interview Question

Regular coding problem