Amazon Robotics interview question

One question in leetcode, mid level difficulty