Files
cpp-flashcards/org/study_deck_02/dsa/sliding-window/0003-longest-substring-without-repeating-characters.org
T

64 lines
1.2 KiB
Org Mode
Raw Normal View History

#+PROPERTY: 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
class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
#+end_src
** TODO C++
#+begin_src cpp
class Solution {
public:
int lengthOfLongestSubstring(string s) {
}
};
#+end_src