String - 10: Longest sub-string length with no repeating characters | Java Implementation

preview_player
Показать описание
Solution:
- We take a Map, which'll give me info about unique characters present, Map key will be character & value will be the last position of that character
- We'll take a max_length variable, where we'll store the solution
- we'll take two variable start & end, which'll be the window of substring with no repeating characters. At starting, both start & end will be at zero
- Now we iterate the string & check if character already present in map then my next window will be from the next character of that character so we get the index point 'start' to that index + 1
- max_length will be updated by end - start + 1
- At last we return, max_length as answer

Time Complexity: O(n)
Space Complexity: O(n)

Do Watch video for more info

CHECK OUT CODING SIMPLIFIED

★☆★ VIEW THE BLOG POST: ★☆★

I started my YouTube channel, Coding Simplified, during Dec of 2015.
Since then, I've published over 400+ videos.

★☆★ SUBSCRIBE TO ME ON YOUTUBE: ★☆★

★☆★ Send us mail at: ★☆★
Рекомендации по теме
Комментарии
Автор

Super speechless. very clear ..every usecase is covered.

ramavempaty
Автор

Hi Bro, This is one of best explanation on internet for this problem because you are clearly representing the steps using the table at bottom.

dearvivekkumar
Автор

Great explanation.. Highly appreciated😊

vidhibansal
Автор

Thank you sir, it was very helpful !!!

meghnasingh
Автор

Good explanation.

You missed updating the index value for "a" and "b"

venkateswarank
Автор

amazing vids and make more based on Leetcode problem

sincelife
Автор

Good work sir
Can you please add some videos on questions of graphs?? Till now you have only taught DFS and BFS but we want you to teach questions on graph too, Please add them👃🏻👃🏻

AyushKumar-vhpg
visit shbcf.ru