240
笔下虽有千言,胸中实无一策
摘要: 题解 双指针法,移动窗口法(Sliding Window) 很重要的题。 这道题要求地很细,移动窗口的时候,要同时记录,开始位置、长度和包含目标字符的个数count。 class Solution { public: string minWindow(string s, string t) { in 阅读全文
posted @ 2020-09-20 10:04 CasperWin 阅读(93) 评论(0) 推荐(0) 编辑
摘要: ##题解 很简单。 class Solution { public: vector<int> plusOne(vector<int>& digits) { int carry = 1; for(int i = digits.size()-1; i >= 0; i--) { int temp = ca 阅读全文
posted @ 2020-09-20 09:02 CasperWin 阅读(60) 评论(0) 推荐(0) 编辑
摘要: 题解 入门级的动态规划题。 class Solution { public: bool canJump(vector<int>& nums) { // dp[i] = dp[i-1] vector<int> dp(nums.size(), false); dp[0] = true; for(int 阅读全文
posted @ 2020-09-20 08:54 CasperWin 阅读(74) 评论(0) 推荐(0) 编辑
摘要: 题解 双指针法 area = (j-i)*min(height[i], height[j]); class Solution { public: int maxArea(vector<int>& height) { int max_area = 0; int l = 0, r = height.si 阅读全文
posted @ 2020-09-20 08:00 CasperWin 阅读(88) 评论(0) 推荐(0) 编辑