Dec 31, 2023
or maybe you can use Set,
Set<Character> set ...
left, right = 0;
while(right<s.length())
if(!set.contains(s.charAt(right)){
right ++
maxLen = Math.max(maxL, right-left)
} else {
set.remove(s.charAt(left))
left ++
}
return maxLen
or maybe you can use Set,
Set<Character> set ...
left, right = 0;
while(right<s.length())
if(!set.contains(s.charAt(right)){
right ++
maxLen = Math.max(maxL, right-left)
} else {
set.remove(s.charAt(left))
left ++
}
return maxLen
Problem Solver | Senior Software Engineer at Infor Nexus