Given a string s, find the length of the longest substring without repeating characters.
Example 1:
Input: s = "abcabcbb"
Output: 3
Explanation: The answer is "abc", with the length of 3.
Example 2:
Input: s = "bbbbb"
Output: 1
Explanation: The answer is "b", with the length of 1.
Example 3:
Input: s = "pwwkew"
Output: 3
Explanation: The answer is "wke", with the length of 3.
Notice that the answer must be a substring, "pwke" is a subsequence and not a substring.
[a,b,c,a,b,c,b,b]
l = 0, r = 0 charSet = {a}
l = 0, r = 1 charSet = {a, b}
l = 0, r = 2 charSet = {a, b, c}
l = 1, r = 3 charSet = {b,c} --> {b,c,a} // remove 'a' --> increment left to 1 --> add 'a' to charSet
...

https://leetcode.com/problems/longest-substring-without-repeating-characters/solutions/?envType=featured-list&envId=top-interview-questions?envType=featured-list&envId=top-interview-questions
'LEETCODE' 카테고리의 다른 글
#11. Container With Most Water [Two Ptr] (0) | 2023.10.12 |
---|---|
#7. Reverse Integer (0) | 2023.10.10 |
#5. Longest Palindromic Substring (even/odd ptrs) (0) | 2023.10.10 |
# 17. Letter Combinations of a Phone Number [BACKTRACK, DFS] (0) | 2023.10.08 |
#19. Remove Nth Node From End of List [Sliding window] (0) | 2023.10.07 |