Leetcode 26-11-2023
Sun Nov 26 2023 18:03:26 GMT+0000 (Coordinated Universal Time)
Saved by
@samee
3. Longest Substring Without Repeating Characters
class Solution {
public int lengthOfLongestSubstring(String s) {
int arr[]=new int[122];
char c[]=s.toCharArray();
int m=0,m1=0;
for(int i=0;i<c.length;i++){
if(arr[c[i]]==0){
arr[c[i]]=1;
m++;
} else {
// m1=Math.max(m1,m);
Arrays.fill(arr,0);
m=0;i--;
}
m1=Math.max(m1,m);
}
return m1;
}
}
content_copyCOPY
Comments