filmov
tv
Minimum Add to Make Parentheses Valid | Simple Intuition | Leetcode 921 | codestorywithMIK

Показать описание
This is the 24th Video of our Playlist "Stack : Popular Interview Problems" by codestorywithMIK
In this video we will try to solve an easy stack based Problem : Minimum Add to Make Parentheses Valid | Simple Intuition | Leetcode 921 | 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 : Minimum Add to Make Parentheses Valid | Simple Intuition | Leetcode 921 | codestorywithMIK
Company Tags : META
╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
Summary :
Stack-Based Approach:
Logic: Uses a stack to track unmatched opening parentheses (. For each closing parenthesis ), if there is a corresponding opening parenthesis in the stack, it is popped; otherwise, a counter (open) is incremented for unmatched closing parentheses.
Complexity:
Time: O(n)
Space: O(n) (due to stack usage)
Counter-Based Approach:
Logic: This approach uses two integer counters: size to track unmatched opening parentheses and open to count unmatched closing parentheses. It iterates through the string, incrementing size for each ( and decrementing it for each ) if there are unmatched opening parentheses (size greater than 0). If there are no unmatched opening parentheses, it increments open.
Final Calculation: The result is open + size, representing the total number of parentheses needed to balance the string.
Complexity:
Time: O(n)
Space: O(1) (constant space, as it only uses integer variables)
✨ 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 #easyexplaination #interview#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 #softwareengineering #computerscience #pythoncoding #codinglife #coderlife #javascript #datascience #leetcode #leetcodesolutions #leetcodedailychallenge #codinginterview #interviewprep #technicalinterview #interviewtips #interviewquestions #codingchallenges #interviewready #dsa #hindi #india #hindicoding #hindiprogramming #hindiexplanation #hindidevelopers #hinditech #hindilearning #helpajobseeker #jobseekers #jobsearchtips #careergoals #careerdevelopment #jobhunt #jobinterview #github #designthinking #learningtogether #growthmindset #digitalcontent #techcontent #socialmediagrowth #contentcreation #instagramreels #videomarketing #codestorywithmik #codestorywithmick #codestorywithmikc #codestorywitmik #codestorywthmik #codstorywithmik #codestorywihmik #codestorywithmiik #codeistorywithmik #codestorywithmk #codestorywitmick #codestorymik #codestorwithmik
In this video we will try to solve an easy stack based Problem : Minimum Add to Make Parentheses Valid | Simple Intuition | Leetcode 921 | 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 : Minimum Add to Make Parentheses Valid | Simple Intuition | Leetcode 921 | codestorywithMIK
Company Tags : META
╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
Summary :
Stack-Based Approach:
Logic: Uses a stack to track unmatched opening parentheses (. For each closing parenthesis ), if there is a corresponding opening parenthesis in the stack, it is popped; otherwise, a counter (open) is incremented for unmatched closing parentheses.
Complexity:
Time: O(n)
Space: O(n) (due to stack usage)
Counter-Based Approach:
Logic: This approach uses two integer counters: size to track unmatched opening parentheses and open to count unmatched closing parentheses. It iterates through the string, incrementing size for each ( and decrementing it for each ) if there are unmatched opening parentheses (size greater than 0). If there are no unmatched opening parentheses, it increments open.
Final Calculation: The result is open + size, representing the total number of parentheses needed to balance the string.
Complexity:
Time: O(n)
Space: O(1) (constant space, as it only uses integer variables)
✨ 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 #easyexplaination #interview#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 #softwareengineering #computerscience #pythoncoding #codinglife #coderlife #javascript #datascience #leetcode #leetcodesolutions #leetcodedailychallenge #codinginterview #interviewprep #technicalinterview #interviewtips #interviewquestions #codingchallenges #interviewready #dsa #hindi #india #hindicoding #hindiprogramming #hindiexplanation #hindidevelopers #hinditech #hindilearning #helpajobseeker #jobseekers #jobsearchtips #careergoals #careerdevelopment #jobhunt #jobinterview #github #designthinking #learningtogether #growthmindset #digitalcontent #techcontent #socialmediagrowth #contentcreation #instagramreels #videomarketing #codestorywithmik #codestorywithmick #codestorywithmikc #codestorywitmik #codestorywthmik #codstorywithmik #codestorywihmik #codestorywithmiik #codeistorywithmik #codestorywithmk #codestorywitmick #codestorymik #codestorwithmik
Комментарии