leetcode375】的更多相关文章

We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You have to guess which number I picked. Every time you guess wrong, I'll tell you whether the number I picked is higher or lower. However, when you guess a particula…
public class Solution { public int GetMoneyAmount(int n) { , n + ]; , n); } int DP(int[,] t, int s, int e) { ; ) return t[s, e]; int res = int.MaxValue; for (int x = s; x <= e; x++) { ), DP(t, x + , e)); res = Math.Min(res, tmp); } t[s, e] = res; ret…
思路: dp. https://leetcode.com/problems/guess-number-higher-or-lower-ii/discuss/ 实现: class Solution { public: int getMoneyAmount(int n) { ][n + ]; memset(dp, 0x3f, sizeof dp); ; i <= n; i++) dp[i][i] = ; ; i >= ; i--) { ; j <= n; j++) { for (int k…