摘要:
``` 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 阅读全文
摘要:
``` 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()& 阅读全文
摘要:
# 暴力 ``` 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 阅读全文
摘要:
``` 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 阅读全文
摘要:
``` /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), left(nullptr), 阅读全文
摘要:
``` 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; } }; ``` 阅读全文
摘要:
``` class Solution { public: vector findDisappearedNumbers(vector& nums) { vector res; int n=nums.size(),offset=n+1; for(auto &num:nums) { int x=(num) 阅读全文
摘要:
``` 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 阅读全文
摘要:
``` 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 阅读全文
摘要:
``` /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), left(nullptr), 阅读全文