Amazon Robotics interview question

It was a Leetcode medium question.