Загрузка страницы

Sliding Window Algorithm - Longest Substring Without Repeating Characters (LeetCode)

►Support me on Patreon: https://www.patreon.com/michaelmuinos
Join the Discord channel by becoming a supporter on my Patreon!
In this Discord channel, you will be able to...
1. Contact me directly for interview prep advice, tech questions, project ideas, etc.
2. Discuss interview experiences with other members
3. Discuss technical questions with other members
4. Find mock interview partners & more!

Here is a step by step explanation of the algorithm problem "Longest Substring Without Repeating Characters" on the LeetCode platform. This problem is asked at many tech companies including Google, Facebook, Amazon, Uber, Adobe, and many more. In this tutorial video, I go over the sliding window technique.

A sliding window algorithm will form a window, or section, around parts of the data. Incrementally, this window will move over the data and perform some sort of computation. To solve it, we must initialize an i and j pointer mapping to our 0 index in our string. We also must initialize a set data structure to keep track of characters we have seen in our window and a max variable. We move the i pointer forward adding each character to our set. If the character is already in our set, we start moving our j pointer forward and removing at each step. After removals, we will compute the length of our window which is i - j + 1 and assign that value to our max variable.

The time and space complexity of our sliding window solution is O(N) where N is the number of characters we have in our input string.

⭐️ Timestamps ⭐️
00:00 - Introduction
00:25 - Problem Overview
00:54 - Brute Force Approach
01:30 - Sliding Window Overview
02:02 - Full Example Walk-through
06:39 - Code Walk-through
09:21 - Time and Space Complexity

►Follow me on Twitter: https://twitter.com/MichaelMuinos
►Follow me on Github: https://github.com/MichaelMuinos

----------------------------------------------------
Better Days by Lakey Inspired
https://soundcloud.com/lakeyinspired
https://www.youtube.com/channel/UCOmy8wuTpC95lefU5d1dt2Q

Видео Sliding Window Algorithm - Longest Substring Without Repeating Characters (LeetCode) канала Michael Muinos
Показать
Комментарии отсутствуют
Введите заголовок:

Введите адрес ссылки:

Введите адрес видео с YouTube:

Зарегистрируйтесь или войдите с
Информация о видео
1 августа 2020 г. 21:00:00
00:10:22
Яндекс.Метрика