上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 20 下一页
摘要: class Solution { public: int maxDiff(vector<int>& nums) { if(nums.size()==0) return 0; int buy=nums[0],res=0; for (int i = 1; i < nums.size(); i ++ ) 阅读全文
posted @ 2023-05-13 14:08 穿过雾的阴霾 阅读(16) 评论(0) 推荐(0)
摘要: class Solution { public: vector<int> res; deque<int> q; vector<int> maxInWindows(vector<int>& nums, int k) { for (int i = 0; i < nums.size(); i ++ ) { 阅读全文
posted @ 2023-05-13 14:07 穿过雾的阴霾 阅读(11) 评论(0) 推荐(0)
摘要: 思路 暴力就是枚举终点 i,找出里 i 最近的起点 j,再去更新答案,可以发现起点随终点单调往后,因此可以滑动窗口优化 如何快速判断当前窗口是否包含子串所有字符 哈希表 word 存储子串所有字符出现的次数,window 存储当前窗口所有字符出现的次数 变量 cnt 记录当前窗口里,有效字符的个数 阅读全文
posted @ 2023-05-11 14:58 穿过雾的阴霾 阅读(14) 评论(0) 推荐(0)
摘要: class Solution { public: string leftRotateString(string str, int n) { if(str.size()==0) return ""; string t=str.substr(0,n); str=str.substr(n); str=st 阅读全文
posted @ 2023-05-11 13:48 穿过雾的阴霾 阅读(18) 评论(0) 推荐(0)
摘要: class Solution { public: string reverseWords(string s) { if(s.size()==0) return ""; reverse(s.begin(),s.end()); for (int i = 0; i < s.size();) { int j 阅读全文
posted @ 2023-05-11 13:46 穿过雾的阴霾 阅读(19) 评论(0) 推荐(0)
摘要: class Solution { public: bool isScramble(string s1, string s2) { int n=s1.size(); vector<vector<vector<bool> > >f(n,vector<vector<bool>>(n,vector<bool 阅读全文
posted @ 2023-05-10 16:47 穿过雾的阴霾 阅读(12) 评论(0) 推荐(0)
摘要: 暴力 枚举区间起点 i,对于每一个 i,找到最大的 j ,满足 ij 区间和<target class Solution { public: vector<vector<int> > findContinuousSequence(int sum) { vector<vector<int> > res 阅读全文
posted @ 2023-05-10 14:59 穿过雾的阴霾 阅读(11) 评论(0) 推荐(0)
摘要: class Solution { public: vector<int> findNumbersWithSum(vector<int>& nums, int target) { unordered_set<int> hashtable; for(auto i:nums) { if(hashtable 阅读全文
posted @ 2023-05-10 14:12 穿过雾的阴霾 阅读(11) 评论(0) 推荐(0)
摘要: class Solution { public: int maxProfit(vector<int>& prices) { int res=0; for(int i=0;i<prices.size()-1;i++) res+=max(0,prices[i+1]-prices[i]); return 阅读全文
posted @ 2023-05-09 15:54 穿过雾的阴霾 阅读(17) 评论(0) 推荐(0)
摘要: class Solution { public: int maxProfit(vector<int>& prices) { int buy=prices[0],n=prices.size(),res=0;//记录最小值 for(int i=1;i<n;i++)//枚举第几天卖出 { res=max( 阅读全文
posted @ 2023-05-09 15:25 穿过雾的阴霾 阅读(16) 评论(0) 推荐(0)
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 20 下一页