#3 Longest substring without repeating characters

Posted yxcindy

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了#3 Longest substring without repeating characters相关的知识,希望对你有一定的参考价值。

  1. Sliding window

  2. Hashset

  3. Loop through every element inside the string. If the current char is not inside the hashset, push the char into the hashset and update the longest value. If the current char is already inside the hashset, change the left boundary of the sliding window until the current char is not inside the hashset.

  4. Return the longest value.

  5. Time complexity: O(n). Space complexity: O(the size of the hashset)

以上是关于#3 Longest substring without repeating characters的主要内容,如果未能解决你的问题,请参考以下文章

longest-substring-with-at-least-k-repeating-characters

LeetCode 395. Longest Substring with At Least K Repeating Characters

395. Longest Substring with At Least K Repeating Characters

3. Longest Substring Without Repeating Characters

Leetcode: Longest Substring with At Least K Repeating Characters

395. Longest Substring with At Least K Repeating Characters