Back to Browse

3. Longest Substring Without Repeating Characters | Part-1: Brute Force Approach - All Substring

35 views
Sep 2, 2024
5:18

3. Longest Substring Without Repeating Characters [Medium] https://leetcode.com/problems/longest-substring-without-repeating-characters/ Video Chapters: 00:00: Video Content Intro 0:16: Question Understanding 0:39: Solution think through 3:34: Solution Visualization 3:21: Solution Code 4:33: Time & Space Complexity Analysis Solution: Brute Force - All Substring. 1. We use nested loops to generate all possible substrings of the input string. 2. For each substring, we check if it contains all unique characters by comparing its length with the length of its set (which removes duplicates). 3. If a substring with all unique characters is found and it's longer than the current max_length, we update max_length and longest_substring. 4. Finally, we return both the length of the longest substring and the substring itself. Complexity Analysis: Time: O(n^3) Space: O(1) Link to the code: https://github.com/codewonkamentor/LeetCodeChannel/blob/main/3.%20LongestSubstringWithoutRepeatingCharacters%20%5BMed%5D/longest_substring.py Pervious Video: https://youtu.be/Xe2ySmY1fIc Next Video: https://youtu.be/OEKxvUAhxW8 #leetcode #leetcodecoding #leetcodesolution

Download

1 formats

Video Formats

360pmp46.0 MB

Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.

3. Longest Substring Without Repeating Characters | Part-1: Brute Force Approach - All Substring | NatokHD