摘要:
//一维dp还是比较难写的class Solution { public: int uniquePathsWithObstacles(vector>& obstacleGrid) { int m = obstacleGrid[0].size(); int n = obstacleGrid.size(); vector dp(m,1); ... 阅读全文
摘要:
//从理解二维dp到简化成一维dp我用了一年的时间class Solution { public: int uniquePaths(int m, int n) { vector dp(m,1); for(int i=1;i < n;i++){ for(int j=1;j < m;j++){ dp[j]... 阅读全文
摘要:
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; *///注意取模,和空集 class Solution { public: L... 阅读全文
摘要:
class Solution { public: int lengthOfLastWord(string s) { int n = s.size(); int res = 0; int j = 0; for(j=n-1;j >= 0;j--){ if(s[j] != ' ') ... 阅读全文