Contiguous Array | Using same Pattern Approach | Similar Problems | Leetcode 525

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



Duration: 21:19
5,828 views
358


Whatsapp Community Link : https://www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A
This is the 86th Video of our Playlist "Arrays 1D/2D : Popular Interview Problems".
In this video we will try to solve a very good pattern problem : Contiguous Array | Using same Pattern Approach | Similar Problems | Leetcode 525

Share your learnings on LinkedIn, Twitter (X), Instagram, Facebook(Meta) with the hashtag #codestorywithmik & feel free to tag me.

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.

Problem Name : Contiguous Array | Using same Pattern Approach | Similar Problems | Leetcode 525
Company Tags : Meta, Google
My solutions on Github(C++ & JAVA) : https://github.com/MAZHARMIK/Interview_DS_Algo/blob/master/Arrays/Cumulative_Sum(Prefix%20Array)/Contiguous%20Array.cpp
Leetcode Link : https://leetcode.com/problems/contiguous-array/description/


My DP Concepts Playlist : https://youtu.be/7eLMOE1jnls
My Graph Concepts Playlist : https://youtu.be/5JGiZnr6B5w
My Recursion Concepts Playlist : https://www.youtube.com/watch?v=pfb1Zduesi8&list=PLpIkg8OmuX-IBcXsfITH5ql0Lqci1MYPM
My GitHub Repo for interview preparation : https://github.com/MAZHARMIK/Interview_DS_Algo
Subscribe to my channel : https://www.youtube.com/@codestorywithMIK
Instagram : https://www.instagram.com/codestorywithmik/
Facebook : https://www.facebook.com/people/codestorywithmik/100090524295846/
Twitter : https://twitter.com/CSwithMIK


Approaches Summary :
We are using the same pattern approach just like Leetcode-560, 930, 1074.
Leetcode-560, 1074 - https://youtu.be/-SWrz90jCUM?si=9dnkn65t_pgeHgyA
Leetcode 930 - https://youtu.be/5Quv9nnZs34?si=aMNPNqLGPaoluWrR
The provided approach is a solution to a problem aiming to find the maximum length of a contiguous subarray with an equal number of 0s and 1s within a given vector nums. The algorithm utilizes an unordered map mp to store the cumulative sum of the array elements encountered so far, with the key being the cumulative sum and the value being the index at which the sum was achieved. The algorithm iterates through the vector, updating the cumulative sum based on the value of the current element (incrementing by 1 for 1s and decrementing by 1 for 0s). At each step, it checks if the current cumulative sum exists in the map. If it does, it updates the maximum length (maxL) by taking the difference between the current index and the index stored in the map for that cumulative sum. Otherwise, it adds the current cumulative sum and its corresponding index to the map. Finally, the algorithm returns the maximum length found, which represents the length of the longest contiguous subarray with an equal number of 0s and 1s.

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

✨ Timelines✨
00:00 - Introduction
03:22 - Why not Sliding Window ?
06:10 - Intuition using pattern Leetcode-560
10:51 - Complete Dry Run
18:14 - Coding it up
21:03 - Time & Space

#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge#leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview#interviewtips #interviewpreparation #interview_ds_algo #hinglish #github #design #data #google #video #instagram #facebook #leetcode #computerscience #leetcodesolutions #leetcodequestionandanswers #code #learning #dsalgo #dsa #2024 #newyear




Other Videos By codestorywithMIK


2024-03-24Longest Common Suffix Queries | Simple TRIE | Clean Code | Leetcode 3093 | codestorywithMIK
2024-03-24Most Frequent IDs | Complete Intuition | Leetcode 3092 | codestorywithMIK
2024-03-22Reorder List | 3 Approaches | Leetcode 143 | codestorywithMIK
2024-03-21Palindrome Linked List | 4 Approaches | Leetcode 234| codestorywithMIK
2024-03-20Task Scheduler | Using Greedy Only | No Heap | Leetcode 621 | codestorywithMIK
2024-03-19Merge In Between Linked Lists | Easy Straight Forward | AMAZON | Leetcode 1669 | codestorywithMIK
2024-03-18Task Scheduler | Easy Intuition | Using Heap | Leetcode 621 | codestorywithMIK
2024-03-17Minimum Deletions to Make String K-Special | 2 Simple Approaches | Leetcode 3085 | codestorywithMIK
2024-03-16Count Substrings Starting and Ending with Given Character | Leetcode 3084 | codestorywithMIK
2024-03-16Shortest Common Supersequence | 3 Approaches | DP On Strings |DP Concepts & Qns 20|codestorywithMIK
2024-03-15Contiguous Array | Using same Pattern Approach | Similar Problems | Leetcode 525
2024-03-15Trie VS Tree
2024-03-14Binary Subarrays With Sum | 2 Approaches | Detailed Explanation | Leetcode 930
2024-03-13Find the Pivot Integer | 5 Approaches | Easy Explanation | Leetcode 2485
2024-03-12Regular Expression Matching | Brute Force | Optimal | Recursion Concepts And Questions
2024-03-11Shortest Uncommon Substring in an Array | Detailed Intuition | Dry Run | Leetcode 3076 | Contest 388
2024-03-10Custom Sort String | 2 Approaches | Intuition | Meta | Leetcode 791
2024-03-10Maximum Strength of K Disjoint Subarrays | Recursion | Memoization | Leetcode 3077 | Contest 388
2024-03-09Intersection of Two Arrays | 4 Approaches | Leetcode 349
2024-03-08Minimum Common Value | 3 Approaches | Leetcode 2540
2024-03-07Count Elements With Maximum Frequency | One Pass | Two Pass | Leetcode 3005