Longest Substring Without Repeating Chars | Sets and Maps Solution | Detailed Explanation | Geekific

preview_player
Показать описание

In this video we tackle one of the very first LeetCode problems: the Longest Substring Without Repeating Characters, and we do that in detail with the help of two solutions, one using Sets and the other using Maps.

LeetCode Problems solved in this video:

Timestamps:
00:00 Introduction
00:07 Defining the Problem
00:46 Brute Force Approach
01:50 Optimal Solution using Sets
03:53 Optimal Solution using Maps
07:05 Thanks for Watching!

If you found this video helpful, check other Geekific uploads:

#Geekific #CodingInteview #LongestSubstring #Maps #Sets #LeetCode #Java #Google #Amazon #Meta #Microsoft #Apple #Netflix
Рекомендации по теме
Комментарии
Автор

Thanks for your great videos. However I don't get why you don't reset your Map completely (empty the map) and reenter values in it again for the new local string? instead of saying go to max of index.

raminessalat
Автор

I think this golang solution is cleaner


func main() {
characters := "abcddefghii1234567890"
letters := map[string]bool{}
max := 0
for _, character := range characters {
strCharacter := string(character)
if letters[strCharacter] {
letters = map[string]bool{}
}
letters[strCharacter] = true
if len(letters) > max {
max = len(letters)
}
}

fmt.Println(max)
}

gabrieltrinidad
Автор

Do not like to work with strings in this manner, but they are everywhere. So, it's obligatory skill...

manOfPlanetEarth