LeetCode 3: Longest Substring Without Repeating Characters (Sliding Window Python Solution)

Published: 07 March 2024
on channel: CodingNinja
58,785
367

LeetCode 3: Longest Substring Without Repeating Characters explained step by step.

In this video, you’ll learn how to solve the Longest Substring Without Repeating Characters problem using the sliding window technique. This is one of the most important patterns in LeetCode and frequently appears in coding interviews.

We cover 3 different approaches:

Brute force solution
Optimized HashSet approach
Sliding Window technique (most efficient)

You’ll understand:

How to track characters efficiently
How to move the window correctly
Why sliding window reduces time complexity
Clean Python implementation

This is a must-know problem if you want to master string problems and sliding window patterns.

🔍 Keywords:
longest substring without repeating characters solution
leetcode 3 python solution
sliding window explained
longest substring leetcode tutorial
string algorithm sliding window

If you're preparing for coding interviews or practicing LeetCode, this video will help you deeply understand one of the most important algorithm patterns.

#leetcode #slidingwindow #python #algorithms #codinginterview #strings

------------------------------------------------------------------------------------------------------
⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️
If this channel or any of the videos have been helpful to you, consider supporting through membership. It really helps motivate me to keep creating more content. There are 3 membership levels, and the lowest one starts at just 90 yen ($0.61 as of July 22, 2025). Thank you for your support!

⭐ Membership link↓
   / @codingninjaexamazon  
⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️

⭐️ Please subscribe to my channel from here.
   / @codingninjaexamazon  

⭐️ Please upvote my post from here.
https://leetcode.com/problems/longest...

⭐️ Update the video
At 2:13 I say index number usually starts from 0. But right reason to add + 1 is that the difference R - L represents the number of positions between the two indices, not the number of elements including both ends. To correctly count all characters from L to R, including both endpoints, we need to add 1. This ensures the length includes both the starting and ending characters.

------------------------------------------------------------------------------------------------------

■ Timeline
0:05 Explain a basic idea
0:45 Explain the first approach with sliding window and set
10:19 Coding with sliding window and set
11:40 Time Complexity and Space Complexity with sliding window and set
12:22 Explain the second approach with sliding window and hashing
17:51 Coding with sliding window and hashing
19:19 Time Complexity and Space Complexity with sliding window and hashing
19:30 Explain the third approach with the last position
23:12 Coding with the last position approach
24:24 Time Complexity and Space Complexity with the last position approach

■ Blind 75 LeetCode questions
   • Blind 75 LeetCode Questions  

■ Twitter
  / codingninjaaz  

■ Instagram
  / codingninjaaz  

■ Problem Link
https://leetcode.com/problems/longest...

■ Codes in the video
Python, JavaScript, Java and C++ are available from here.
https://leetcode.com/problems/longest...

■ Other Playlists
Array&Hash :    • Video  
Tree :    • Video  
Backtracking :    • Video  
Sliding Window :    • Permutation in String - LeetCode #567 with...  
Greedy :    • Video  
Easy Level Questions :    • Video  
Medium Level Questions :    • Permutation in String - LeetCode #567 with...  
Linked List:    • Video  
Hard Level Questions :   • Merge k Sorted Lists - LeetCode #23 with p...  

#leetcode #python #interview


On this page of the site you can watch the video online LeetCode 3: Longest Substring Without Repeating Characters (Sliding Window Python Solution) with a duration of hours minute second in good quality, which was uploaded by the user CodingNinja 07 March 2024, share the link with friends and acquaintances, this video has already been watched 58,785 times on youtube and it was liked by 367 viewers. Enjoy your viewing!