End of Year Sale: Use Coupon Code END2025 to Get Extra 25% Off.
nums to allow constant time average calculation.dp where dp[i][k] will hold the maximum score for partitioning nums[i:] into k subarrays.dp array starting from the smallest subproblems (largest i and smallest k) and build up to the solution.i and k, consider all possible partitions by iterating over j where i < j <= N, and calculate the score for each partition as the sum of the average of nums[i:j] and dp[j][k-1].dp[0][k], which represents the maximum score for partitioning the entire array into at most k subarrays.