Python Programming Practice: LeetCode #3 -- Longest Substring Without Repeating Characters

preview_player
Показать описание
In this episode of Python Programming Practice, we tackle LeetCode #3 -- Longest Substring Without Repeating Characters.

Link to the problem here:

This is a medium difficulty problem, so getting a passing solution will generally require submitting code that performs better than a naive brute force solution.

Python Programming Practice is a series focused on teaching practical coding skills by solving exercises on popular coding websites. Note that the solutions seen here may not be the most efficient possible.

I am not going to provide the full code in the video description for this series, since copy and pasting solutions is not in the spirit of doing coding exercises. It is intended that the video will help you think about problems, approaches and how to structure solutions so that you are able to code up a working solution yourself. .

Рекомендации по теме
Комментарии
Автор

Best Explanation ever you are the indian youtuber of leetcode

josephstalin
Автор

The legit GOAT. Explanations always soo good. Thank you!

davidutomi
Автор

When I saw the program faster than 99.37% and memory usage less than 100%, I immediately hit the subscribe button.

neotank
Автор

Are you kidding, 0 comments, only 7 upvotes? LIked and subscribed and hoping to see more.

punstress
Автор

Amazing explanation! The way you take your time to visualize the concepts and reinforce ideas even when you're already coding is so helpful. Wish you would do more leetcode in Python, as there is a great need for videos that explain the concepts in depth as you do.

adventurer
Автор

Please make more awesome videos like this, DataDaft!

annas
Автор

I find it extremely helpful watching you talk through the problem solving. It is good to practice talking through problems imitating how you join the dots for myself, so I can at least pretend I understand whats going on :D

loden
Автор

amazing job. please continue to these practices, I'm learning a lot

kacakacamu
Автор

loved it, very clear explanation! thank you!

biluulu
Автор

Nice! What you mentioned about measuring the run time of a solution before writing code is really valuable advice!

mryup
Автор

Its very helpful, please keep making more. Great Work

alkeshace
Автор

Thank you sir. Just starting out with leetcode after a few MOOCs, and this is very helpful. Appreciate it!

mariohage
Автор

please upload more leetcode problem solutions. Loved your teaching skills! Best wishes from India

sreejaroy
Автор

Please add more leetcode question..really liked your explanations

kshitijkhurana
Автор

Thank you. Your explanation is awesome!

NitinSatish
Автор

Clear solution, commenting to support this type of content

winterresearch
Автор

tysm you explanation is very clear and easy to understand

ritikasingh
Автор

Thanks. You can further simplify your idea as follows -

class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
i = 0

max_length = 0

seen = dict()

for j in range(len(s)):
if s[j] in seen.keys():
i = max(i, seen[s[j]] + 1)
seen[s[j]] = j
else:
seen[s[j]] = j

if j - i + 1 > max_length:
max_length = j - i + 1

return max_length

ogsconnect
Автор

ooo God 99% faster than all other and the explanation was very clear. love you man

workhardforyourfamily
Автор

Thank you So much.Your explanation was the best . Great teaching skills.

smritipradhan