Leetcode day1

This commit is contained in:
2026-01-25 12:41:33 +05:30
parent 686d174f19
commit 245116d181
14 changed files with 168 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
class Solution{
public:
int LengthOfLongestSubString(string s){
int n = s.length();
int maxlen = 0;
unordered_set<char> charset;
int left = 0;
for(int right = 0;right<n;right++){
if(charset.count(s[right])==0){
charset.insert(s[right]);
maxlen = max(maxlen, right-left+1);
}while(charset.count(s[right])){
charset.erase(s[left]);
left++;
}
}
return maxlen;
}
}