[LeetCode][3. Longest Substring Without Repeating Characters] Two Pointers: Sliding Window with HashSet
By Long Luo
This article is the solution Two Pointers: Sliding Window with HashSet of Problem 3. Longest Substring Without Repeating Characters.
Intuition
We can just simulate the process.
Using a Sliding Window from left to right of the string, and a HashSet to make every character is unique in the sliding window.
1 | public static int lengthOfLongestSubstring(String s) { |
Analysis
- Time Complexity:
- Space Complexity:
All suggestions are welcome.
If you have any query or suggestion please comment below.
Please upvote👍 if you like💗 it. Thank you:-)
Explore More Leetcode Solutions. 😉😃💗