-
Notifications
You must be signed in to change notification settings - Fork 382
Closed
Description
LeetCode Username
vishwa_7
Problem Number, Title, and Link
Longest Substring Without Repeating Characters,https://leetcode.com/problems/longest-substring-without-repeating-characters/submissions/1780963433
Bug Category
Problem constraints
Bug Description
Longest Substring Without Repeating Characters
Language Used for Code
Java
Code used for Submit/Run operation
class Solution {
public int lengthOfLongestSubstring(String s) {
int n = s.length();
int[] freq = new int[128];
int left = 0, right = 0, maxLen = 0;
while (right < n) {
char c = s.charAt(right);
freq[c]++;
while (freq[c] > 1) {
char d = s.charAt(left);
freq[d]--;
left++;
}
maxLen = Math.max(maxLen, right - left + 1);
right++;
}
return maxLen;
}
}Expected behavior
Longest Substring Without Repeating Characters
it will not repeat the substring
Screenshots
No response
Additional context
No response
Metadata
Metadata
Assignees
Labels
No labels