Files

64 lines
1.3 KiB
Org Mode
Raw Permalink Normal View History

2026-06-01 18:12:40 +08:00
#+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
2026-06-05 22:32:49 +08:00
#+begin_src python :lc-problem 3 :lc-lang python3
class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
#+end_src
** TODO C++
2026-06-05 22:32:49 +08:00
#+begin_src cpp :lc-problem 3
class Solution {
public:
int lengthOfLongestSubstring(string s) {
}
};
#+end_src