I'll show you the bottom-up DP. The outer loop iterates over days, the inner loop over ending indices, and the innermost loop tries each split point.
function minDifficulty(jobDifficulty, d):
n = length(jobDifficulty)
if n < d:
return -1
dp = 2D array of size (d+1) x n, filled with infinity
// Base case: day 1
runningMax = 0
for i from 0 to n-1:
runningMax = max(runningMax, jobDifficulty[i])
dp[1][i] = runningMax
// Fill remaining days
for day from 2 to d:
for i from day-1 to n-1:
currentMax = 0
for j from i down to day-1:
currentMax = max(currentMax, jobDifficulty[j])
dp[day][i] = min(dp[day][i], dp[day-1][j-1] + currentMax)
return dp[d][n-1]