ycliper

Популярное

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

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

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

Топ запросов

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

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

Автор: codestorywithMIK

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

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

Описание: 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

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

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

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

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

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

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

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

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

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

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

Поиск первого и последнего вхождения | Бинарный поиск | Метод перебора | Оптимальный подход |

Поиск первого и последнего вхождения | Бинарный поиск | Метод перебора | Оптимальный подход |

Check if a Parentheses String Can Be Valid | Detailed Intuition | 2 Approaches | Leetcode 2116 | MIK

Check if a Parentheses String Can Be Valid | Detailed Intuition | 2 Approaches | Leetcode 2116 | MIK

Constrained Subsequence Sum | Recursion | Memoization | Sliding Window | GOOGLE | Leetcode - 1425

Constrained Subsequence Sum | Recursion | Memoization | Sliding Window | GOOGLE | Leetcode - 1425

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

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

Хватит позориться такими If-Else! Это выдает в тебе новичка!

Хватит позориться такими If-Else! Это выдает в тебе новичка!

Palindromic Substrings | Blueprint | Palindrome Problems | 4 Approaches | Leetcode 647

Palindromic Substrings | Blueprint | Palindrome Problems | 4 Approaches | Leetcode 647

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

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

Minimum Remove to Make Valid Parentheses | 3 Detailed Approaches | Leetcode 1249 | codestorywithMIK

Minimum Remove to Make Valid Parentheses | 3 Detailed Approaches | Leetcode 1249 | codestorywithMIK

Вся IT-база в ОДНОМ видео: Память, Процессор, Код

Вся IT-база в ОДНОМ видео: Память, Процессор, Код

Valid Parentheses | Stack | Lecture 67

Valid Parentheses | Stack | Lecture 67

First Missing Positive | In Depth Intuition | Clean Code | Leetcode 41 | codestorywithMIK

First Missing Positive | In Depth Intuition | Clean Code | Leetcode 41 | codestorywithMIK

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

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

L11. Valid Parenthesis String | Multiple Approaches

L11. Valid Parenthesis String | Multiple Approaches

Метки разделов — Leetcode 763 — Python

Метки разделов — Leetcode 763 — Python

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

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

«Международная версия» Windows 11 (English International)

«Международная версия» Windows 11 (English International)

I Made a Classic Refactoring Mistake

I Made a Classic Refactoring Mistake

Корректные скобки (LeetCode 20) | Полное решение с визуальными эффектами и анимацией | Структура ...

Корректные скобки (LeetCode 20) | Полное решение с визуальными эффектами и анимацией | Структура ...

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



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



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