Sendoso interview question

Leetcode Easy Mars Rover type question