You are right I think, I got the same problem.
K
kite
@kite
11
Reputation
5
Posts
43
Profile views
0
Followers
0
Following
Posts made by kite

RE: The problem should state that "the Knight cannot enter the same room more than once"
The problem states:
In order to reach the princess as quickly as possible, the knight decides to move only rightward or downward in each step.

Share my c++ DP solution with explanation
###dp[i][j] means start from point (i,j) end at point (n1,m1) need at least dp[i][j] health.###
dp[i][j] = min( max( dp[i+1][j]  dungeon[i][j], 1),
max( dp[i][j+1]  dungeon[i][j], 1) );class Solution { public: int calculateMinimumHP(vector<vector<int> > &dungeon) { int n = dungeon.size(); int m = dungeon[0].size(); int dp[n][m]; memset(dp,0,sizeof(dp)); for(int i=n1;i>=0;i){ for(int j=m1; j>=0; j){ if(i+1==n && j+1 == m){ dp[i][j] = max(1dungeon[i][j],1); continue; } if(j+1<m){ dp[i][j] = max(dp[i][j+1]  dungeon[i][j],1); } if(i+1<n){ if(dp[i][j]) dp[i][j] = min(dp[i][j],max(dp[i+1][j]  dungeon[i][j],1)); else dp[i][j] = max(dp[i+1][j]dungeon[i][j],1); } } } return dp[0][0]; } };

RE: MLE,and got no idea why ...
you may try this：
origin:
TreeNode *buildTree2(vector<int> inorder,vector<int> postorder,It inbg,It ined,It pobg,It poed)modified:
TreeNode *buildTree2(vector<int>& inorder,vector<int>& postorder,It inbg,It ined,It pobg,It poed)