dp with 26 elements to 0, representing the 26 letters of the alphabet.res to 0 and save to 0. res will hold the total distance if typed by one finger, and save will hold the maximum distance saved by using two fingers.b and c, calculate the distance d(b, c).a in the alphabet, update dp[b] with the maximum of dp[b] and dp[a] + d(b, c) - d(a, c).save with the maximum of save and dp[b].d(b, c) to res.res - save as the result.