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