题解 | #牛牛的跳跃挑战#
牛牛的跳跃挑战
https://www.nowcoder.com/practice/0c99c2161c2d4a4e91ca55363cc0e059
class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param height int整型vector * @return int整型 */ int minEnergyJump(vector<int>& height) { // write code here int length = height.size(); vector<int> dp(length+3, 0); for (int i = length-1; i >= 0; i--) { dp[i] = height[i] + min(min(dp[i+1], dp[i+2]), dp[i+3]); } return min(min(dp[0], dp[1]), dp[2]); } };