#+ANKI_DECK: study_deck_02 * TODO 0003. Longest Substring Without Repeating Characters :medium: :PROPERTIES: :NEETCODE: [[file:../../roadmap.org::*0003. Longest Substring Without Repeating Characters][0003. Longest Substring Without Repeating Characters]] :END: Given a string ~s~, find the length of the *longest* *substring* without duplicate characters. *Example 1:* #+begin_src Input: s = "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3. Note that "bca" and "cab" are also correct answers. #+end_src *Example 2:* #+begin_src Input: s = "bbbbb" Output: 1 Explanation: The answer is "b", with the length of 1. #+end_src *Example 3:* #+begin_src 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. #+end_src *Constraints:* - ~0 <= s.length <= 5 * 10^{4}~ - ~s~ consists of English letters, digits, symbols and spaces. ** TODO Approach Write your approach here. ** TODO Python #+begin_src python :lc-problem 3 :lc-lang python3 class Solution: def lengthOfLongestSubstring(self, s: str) -> int: #+end_src ** TODO C++ #+begin_src cpp :lc-problem 3 class Solution { public: int lengthOfLongestSubstring(string s) { } }; #+end_src