![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode
罗蜜斯丹
那些人好奇怪啊?怎么一直在盯着人家的简述?
展开
-
解题法-滑动窗口
3. 无重复字符的最长子串使用set来存储窗口 int lengthOfLongestSubstring(string s) { unordered_set<char> set; int ans = 0, right = 0; for (int i=0; i < s.length(); i++) { // 右指针右移,直到遇到重复字符 wh.原创 2020-08-29 14:24:27 · 192 阅读 · 0 评论 -
560. 和为K的子数组
原创 2020-08-27 23:24:11 · 121 阅读 · 0 评论 -
325. 和等于 k 的最长子数组长度
class Solution {public: int maxSubArrayLen(vector<int>& nums, int k) { map<int, int> hash; int sum = 0; hash[0] = 0; int ans = 0; // 从效率的角度,不应该使用count,应该使用find for(int len=0; len <...原创 2020-08-27 23:01:35 · 187 阅读 · 0 评论