Company: Cashfree_6nov
Difficulty: medium
Efficient Hiking Problem Description A hiker plans a multi-day trek through mountains with `n` trails of specific lengths provided in a list called `trails`. The trails must be hiked in the given order. The hiker aims to complete the trek in the minimum number of days, with at least one trail hiked each day. The objective is to minimize the sum of the lengths of the longest trail hiked each day. Determine this minimum sum. Complete the function `efficientTrek` in the editor with the following parameters: `int[] trails`: an array of integers denoting the order and length of the trails. `int record`: the number of days to cover all the trails. Returns: `int`: the minimum sum of the longest trails on each day. Examples Example 1: Input: 5 150 200 400 350 250 3 Output: 750 Explanation: Given `n = 5`, `trails = [150, 200, 400, 350, 250]`, and `record = 3`. The hiker covers the first trail on day 1, the second on day 2, and the remaining trails on day 3. Day 1: `[150]` (longest = 150) Day 2: