FedEx Interview Question

Leetcode problem from easy to medium pool