{ maxProfit([] prices) { maxProfit(,prices); } maxProfit( k, [] prices) { n prices.length; (n ) { ; } [][][] dp [n][k][]; ( i ; i n; i) { ( j k; j ; j) { (i){ dp[i][j][]; dp[i][j][]prices[i]; ; } dp[i][j][]Math.max(dp[i][j][],dp[i][j][]prices[i]); dp[i][j][]Math.max(dp[i][j][],dp[i][j][]prices[i]); } } dp[n][k][]; } }
不会,我可以学;落后,我可以追赶;跌倒,我可以站起来!