Find the Longest Substring Containing Vowels in Even Counts | Leetcode 1371 | codestorywithMIK

Subscribers:
92,300
Published on ● Video Link: https://www.youtube.com/watch?v=6Xf5LfM-ciI



Duration: 0:00
12,836 views
747


Whatsapp Community Link : https://www.whatsapp.com/channel/0029...
This is the 19th Video of our Playlist "Bit Manipulation : Popular Interview Problems" by codestorywithMIK
We will also see why sliding window is not a feasible solution for this.

In this video we will try to solve an easy problem : Find the Longest Substring Containing Vowels in Even Counts | Multiple Ways | Leetcode 1371 | codestorywithMIK

I will explain the intuition so easily that you will never forget and start seeing this as cakewalk EASYYY.
We will do live coding after explanation and see if we are able to pass all the test cases.
Also, please note that my Github solution link below contains both C++ as well as JAVA code.

Problem Name : Find the Longest Substring Containing Vowels in Even Counts | Multiple Ways | Leetcode 1371 | codestorywithMIK
Company Tags : Yogiyo (Food delivering app)
My solutions on Github(C++ & JAVA) : https://github.com/MAZHARMIK/Intervie...
Leetcode Link : https://leetcode.com/problems/find-th...


My DP Concepts Playlist :    • Roadmap for DP | How to Start DP ? | ...  
My Graph Concepts Playlist :    • Graph Concepts & Qns - 1 : Graph will...  
My Recursion Concepts Playlist :    • Introduction | Recursion Concepts And...  
My GitHub Repo for interview preparation : https://github.com/MAZHARMIK/Intervie...
Instagram :   / codestorywithmik  
Facebook :   / 100090524295846  
Twitter :   / cswithmik  
Subscribe to my channel :    / @codestorywithmik  

╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝

Summary :
Approach 1 (Using a Map to Store States)

Time Complexity (T.C.): O(n)
Space Complexity (S.C.): O(1)
Description: This approach uses an unordered map to track the state of vowels in the string (whether their counts are even or odd). It maintains a vector that tracks the count of the five vowels (a, e, i, o, u), and for each character, updates the state of the vowels. If a state (string of binary digits representing vowel parity) is found in the map, it calculates the substring length. Otherwise, it stores the first occurrence of that state in the map. The solution ensures that all vowel counts are even to find the longest valid substring.
Approach 2 (Using XOR for State and Map)

Time Complexity (T.C.): O(n)
Space Complexity (S.C.): O(1)
Description: This approach is similar to the first but uses XOR to toggle the vowel counts between even and odd. The idea is to flip the state of a vowel (0 to 1 and vice versa) using XOR for each occurrence. Like the first approach, a map is used to store the first occurrence of each state. XOR makes the approach more efficient in handling bitwise operations, and a string representing the state is used to track the current state of vowels in binary form.
Approach 3 (Using Mask and XOR)

Time Complexity (T.C.): O(n)
Space Complexity (S.C.): O(1)
Description: This approach uses bit manipulation, representing the state of the five vowels using a 5-bit mask. Each vowel corresponds to a specific bit position, and XOR is used to toggle the bits in the mask when a vowel is encountered. The mask is stored in an unordered map with its first occurrence. If the current mask was seen before, the length of the substring is calculated. This approach reduces space complexity since it only needs to track at most 25 states, making it highly efficient for this problem.
All three approaches maintain O(n) time complexity and optimize the space complexity using bit manipulation, with Approach 3 being the most space-efficient due to the use of a bitmask.


✨ Timelines✨
00:00 - Introduction

#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge#leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #interviewtips #interviewpreparation #interview_ds_algo #hinglish #github #design #data #google #video #instagram #facebook #leetcode #computerscience #leetcodesolutions #leetcodequestionandanswers #code #learning #dsalgo #dsa #coding #programming #100daysofcode #developers #techjobs #datastructures #algorithms #webdevelopment #hindiexplanation #hindidevelopers #hinditech #hindilearning #helpajobseeker #careergoals #careerdevelopment #jobhunt #jobinterview #github #designthinking #learningtogether #growthmindset #digitalcontent #techcontent #socialmediagrowth #contentcreation #instagramreels #videomarketing #codestorywithmik #codestorywithmick #codestorywithmikc #codestorywitmik #codestorywthmik #codstorywithmik




Other Videos By codestorywithMIK


2024-09-25My Calendar I | Detailed Approach | Leetcode 729 | codestorywithMIK
2024-09-24Sum of Prefix Scores of Strings | Trie | Full Easy Dry Run | Leetcode 2416 | codestorywithMIK
2024-09-23Find the Length of the Longest Common Prefix | 2 Approaches | Leetcode 3043 | codestorywithMIK
2024-09-22Extra Characters in a String | Recursion | Bottom Up | Easy | Leetcode 2707 | codestorywithMIK
2024-09-22K-th Smallest in Lexicographical Order | Super Detailed | Dry Run | Leetcode 440 | codestorywithMIK
2024-09-20Lexicographical Numbers | Simple DFS | Leetcode 386 | codestorywithMIK
2024-09-20Shortest Palindrome | Multiple Ways | KMP Zindabaad | Leetcode 214 | codestorywithMIK
2024-09-18Different Ways to Add Parentheses | Simple Story To Code | Leetcode 241 | codestorywithMIK
2024-09-15Minimum Time Difference | Easy Approach | Detailed | Leetcode 539 | codestorywithMIK
2024-09-15DSA Shorts with MIK - 4
2024-09-15Find the Longest Substring Containing Vowels in Even Counts | Leetcode 1371 | codestorywithMIK
2024-09-14DSA Shorts with MIK - 3
2024-09-13Longest Subarray With Maximum Bitwise AND | Simple Observation | Leetcode 2419 | codestorywithMIK
2024-09-12XOR Queries of a Subarray | Simple Explanation | Leetcode 1310 | codestorywithMIK
2024-09-11Count the Number of Consistent Strings | Using Bit Manipulation | Leetcode 1684 | codestorywithMIK
2024-09-09Insert Greatest Common Divisors in Linked List | 2 Approaches | Leetcode 2807 | codestorywithMIK
2024-09-08Maximum Number of Moves to Kill All Pawns | Step By Step Detailed | Leetcode 3283 | codestorywithMIK
2024-09-08Leetcode Contest Qn-4 ka Khauf
2024-09-06Linked List in Binary Tree | Easy | Dry Run | Leetcode 1367 | codestorywithMIK
2024-09-05Delete Nodes From Linked List Present in Array | Simple | Dry Run | Leetcode 3217 | codestorywithMIK
2024-09-04Walking Robot Simulation | Detailed Simulation | Leetcode 874 | codestorywithMIK



Other Statistics

Counter-Strike: Source Statistics For codestorywithMIK

At this time, codestorywithMIK has 34,577 views for Counter-Strike: Source spread across 5 videos. Less than an hour worth of Counter-Strike: Source videos were uploaded to his channel, making up less than 0.10% of the total overall content on codestorywithMIK's YouTube channel.