FedEx interview question

Leetcode problem from easy to medium pool