leetcode3题
重新学习了下红黑树 平衡二叉树 堆
mysql 5讲
两篇面经学习
今天状态不是很好
``` //笔记将同步在小程序中,便于复 class Solution { public: int trap(vector<int>& height) { int area = 0,pre = 0,ans = 0; for(int i = 1; i < height.size(); i ++){ if(height[i] >= height[pre]) { ans = ans + area; pre = i; area = 0; continue; } area += height[pre] - height[i]; } area = 0; pre = height.size() - 1; for(int i = height.size() - 2; i >= 0; i --){ if(height[i] > height[pre]) { ans = ans + area; pre = i; area = 0; continue; } area += height[pre] - height[i]; } return ans; } }; ```
class Solution { public: int dp[550][550] = {0}; int minDistance(string word1, string word2) { for(int i = 0; i <= word2.size(); i ++){ dp[0][i] = i; } for(int i = 0; i <= word1.size(); i ++){ dp[i][0] = i; } for(int i = 1; i <= word1.size(); i ++){ for(int j = 1; j <= word2.size(); j ++){ if(word1[i - 1] == word2[j - 1]){ dp[i][j] = min(dp[i - 1][j - 1],min(dp[i - 1][j] + 1,dp[i][j - 1] + 1)); } else { dp[i][j] = min(dp[i - 1][j - 1] + 1,min(dp[i - 1][j] + 1,dp[i][j - 1] + 1)); } } } return dp[word1.size()][word2.size()]; } };