摘要: ``` class Solution { public: int res=0; int lengthOfLongestSubstring(string s) { int n=s.size (); if(!n) return 0; bool st[128]={false}; for(int j=0,i 阅读全文
posted @ 2023-08-05 11:06 穿过雾的阴霾 阅读(6) 评论(0) 推荐(0) 编辑
摘要: ``` class Solution { public: vector dailyTemperatures(vector& t) { stack st; int n=t.size(); vector res(n); for(int i=n-1;i>=0;i--) { while(st.size()& 阅读全文
posted @ 2023-08-04 12:14 穿过雾的阴霾 阅读(9) 评论(0) 推荐(0) 编辑
摘要: # 暴力 ``` class Solution { public: int res=0; int countSubstrings(string s) { int n=s.size(); for(int i=0;i=0&&r=0&&r> f(n+1,vector(n+1,false)); for(in 阅读全文
posted @ 2023-08-03 10:55 穿过雾的阴霾 阅读(5) 评论(0) 推荐(0) 编辑
摘要: ``` class Solution { public: int findUnsortedSubarray(vector& nums) { int n=nums.size(); int l=0,r=n-1; while(l0&&nums[r]>=nums[r-1]) r--; int min_num 阅读全文
posted @ 2023-08-01 11:03 穿过雾的阴霾 阅读(4) 评论(0) 推荐(0) 编辑
摘要: ``` /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), left(nullptr), 阅读全文
posted @ 2023-08-01 10:18 穿过雾的阴霾 阅读(8) 评论(0) 推荐(0) 编辑
摘要: ``` class Solution { public: int hammingDistance(int x, int y) { int cnt=0; int t=x^y; while(t) { cnt+=(t&1); t>>=1; } return cnt; } }; ``` 阅读全文
posted @ 2023-07-30 22:29 穿过雾的阴霾 阅读(5) 评论(0) 推荐(0) 编辑
摘要: ``` class Solution { public: vector findDisappearedNumbers(vector& nums) { vector res; int n=nums.size(),offset=n+1; for(auto &num:nums) { int x=(num) 阅读全文
posted @ 2023-07-29 13:54 穿过雾的阴霾 阅读(9) 评论(0) 推荐(0) 编辑
摘要: ``` class Solution { public: vector findAnagrams(string s, string p) { unordered_map window,hash; vector res; for(auto i:p) hash[i]++; for(int i=0,j=0 阅读全文
posted @ 2023-07-28 12:30 穿过雾的阴霾 阅读(5) 评论(0) 推荐(1) 编辑
摘要: ``` class Solution { public: int subarraySum(vector& nums, int k) { int n=nums.size(),res=0; vector s(n+1,0); unordered_map hash;//记录端点i之前所有前缀和的出现情况 f 阅读全文
posted @ 2023-07-26 12:26 穿过雾的阴霾 阅读(4) 评论(0) 推荐(0) 编辑
摘要: ``` /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), left(nullptr), 阅读全文
posted @ 2023-07-26 11:56 穿过雾的阴霾 阅读(6) 评论(0) 推荐(0) 编辑
点击右上角即可分享
微信分享提示