ycliper

Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
Скачать

Valid Parenthesis String | 4 Detailed Approaches | Leetcode 678 | codestorywithMIK

Автор: codestorywithMIK

Загружено: 2024-04-07

Просмотров: 13438

Описание: Whatsapp Community Link : https://www.whatsapp.com/channel/0029...
This is the 90thVideo of our Playlist "Dynamic Programming : Popular Interview Problems".

In this video we will try to solve a very good problem : Valid Parenthesis String | Leetcode 678

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 : Valid Parenthesis String | 4 Detailed Approaches | Leetcode 678 | codestorywithMIK
Company Tags : META
My solutions on Github(C++ & JAVA) : https://github.com/MAZHARMIK/Intervie...
Leetcode Link : https://leetcode.com/problems/valid-p...


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

Approach Summary :
*Approach-1 (Using Recursion + Memoization):*
This approach utilizes recursion along with memoization to solve the problem. It defines a recursive function to check if the given string is valid or not, considering different possibilities of treating '*' as '(', ')', or empty. Memoization is used to store already computed states, which reduces redundant computation. This approach has a time complexity of O(n^2) and a space complexity of O(n^2).

*Approach-2 (Using Bottom-Up Dynamic Programming):*
Here, bottom-up dynamic programming is employed to solve the problem. It defines a 2D DP table where each state represents whether a substring from index i to n-1 is valid or not, considering the count of open brackets. The algorithm iterates through the string from right to left, updating the DP table based on the current character and the previously computed states. This approach has a time complexity of O(n^2) and a space complexity of O(n^2).

*Approach-3 (Using Two Stacks):*
This approach utilizes two stacks to keep track of open brackets and asterisks encountered in the string. It iterates through the string, pushing open brackets and asterisks onto their respective stacks and popping them when encountering a closing bracket. The algorithm also handles cases where there are excess open brackets or asterisks using post-processing. This approach has a time complexity of O(n) and a space complexity of O(n).

*Approach-4 (Constant Space):*
This approach aims to solve the problem using constant space. It iterates through the string twice, first from left to right to count open brackets and then from right to left to count closing brackets. At each step, it updates the counts based on the current character. If the count of open or close brackets becomes negative at any point, it indicates invalidity. This approach has a time complexity of O(n) and a space complexity of O(1).

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

✨ Timelines✨
00:00 - Introduction
4:16 - Approach-1
15:44 - Coding Approach-1
20:00 - Approach-2
36:32 - Coding Approach-2
45:52 - Approach-3
57:36 - Coding Approach-3
1:48:00 - Approach-4
1:11:12 - Coding Approach-4




#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 #newyear2024

Не удается загрузить Youtube-плеер. Проверьте блокировку Youtube в вашей сети.
Повторяем попытку...
Valid Parenthesis String | 4 Detailed Approaches | Leetcode 678 | codestorywithMIK

Поделиться в:

Доступные форматы для скачивания:

Скачать видео

  • Информация по загрузке:

Скачать аудио

Похожие видео

Допустимая строка в скобках — Leetcode 678 — Python

Допустимая строка в скобках — Leetcode 678 — Python

Minimum Sum of Values by Dividing Array | Recursion | Memoization | Leetcode 3117 | codestorywithMIK

Minimum Sum of Values by Dividing Array | Recursion | Memoization | Leetcode 3117 | codestorywithMIK

Learning Odin + Raylib in 2026

Learning Odin + Raylib in 2026

L11. Valid Parenthesis String | Multiple Approaches

L11. Valid Parenthesis String | Multiple Approaches

Допустимая строка скобок | Leetcode #678

Допустимая строка скобок | Leetcode #678

Leetcode 32 — самые длинные допустимые скобки

Leetcode 32 — самые длинные допустимые скобки

K Inverse Pairs Array | Recursion | Memoization | Bottom Up | Optimal Bottom Up | Leetcode 629

K Inverse Pairs Array | Recursion | Memoization | Bottom Up | Optimal Bottom Up | Leetcode 629

Maximal Rectangle | Multiple Hidden Problems | Intuition | Leetcode 85 | codestorywithMIK

Maximal Rectangle | Multiple Hidden Problems | Intuition | Leetcode 85 | codestorywithMIK

Как решить ЛЮБУЮ проблему LeetCode (шаг за шагом)

Как решить ЛЮБУЮ проблему LeetCode (шаг за шагом)

Gas Station (LeetCode 134) | Full Solution with Diagrams and animation | Greedy Approach

Gas Station (LeetCode 134) | Full Solution with Diagrams and animation | Greedy Approach

Русский пост-панк | Russian Doomer Music | Плейлист для вечерних посиделок

Русский пост-панк | Russian Doomer Music | Плейлист для вечерних посиделок

Check if a Parentheses String Can Be Valid | Leetcode 2116

Check if a Parentheses String Can Be Valid | Leetcode 2116

Minimum Difficulty of a Job Schedule | Recursion | Memoization | Amazon | Leetcode 1335

Minimum Difficulty of a Job Schedule | Recursion | Memoization | Amazon | Leetcode 1335

4 Hours Chopin for Studying, Concentration & Relaxation

4 Hours Chopin for Studying, Concentration & Relaxation

Maximum Number of Points with Cost | Detailed Explanation | Leetcode 1937 | codestorywithMIK

Maximum Number of Points with Cost | Detailed Explanation | Leetcode 1937 | codestorywithMIK

Valid Parentheses | Stack | Lecture 67

Valid Parentheses | Stack | Lecture 67

Если у тебя спросили «Как твои дела?» — НЕ ГОВОРИ! Ты теряешь свою силу | Еврейская мудрость

Если у тебя спросили «Как твои дела?» — НЕ ГОВОРИ! Ты теряешь свою силу | Еврейская мудрость

I Made a Classic Refactoring Mistake

I Made a Classic Refactoring Mistake

Новости мира Python за декабрь 2025

Новости мира Python за декабрь 2025

Domino and Tromino Tiling | Detailed Explanations | Leetcode 790 | codestorywithMIK

Domino and Tromino Tiling | Detailed Explanations | Leetcode 790 | codestorywithMIK

© 2025 ycliper. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: [email protected]