Amazon Robotics Interview Question

some basic problem about recursion