Minimum Total Distance Traveled | Recursion | DP | Leetcode 2463