ycliper

Популярное

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

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

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

Топ запросов

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

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

Автор: codestorywithMIK

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

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

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

L11. Valid Parenthesis String | Multiple Approaches

L11. Valid Parenthesis String | Multiple Approaches

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

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

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

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

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

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

Дерек уходит из Veritasium?

Дерек уходит из Veritasium?

Будет ли встраиваемые системы по-прежнему привлекательной карьерой в 2026 году?

Будет ли встраиваемые системы по-прежнему привлекательной карьерой в 2026 году?

Mongo DB v1 4k+ Boot Dev

Mongo DB v1 4k+ Boot Dev

Claude Code is about to break everything

Claude Code is about to break everything

Smallest Sufficient Team | Recur + Memo | Bit Manipulation Made Easy | AMAZON | Leetcode-1125

Smallest Sufficient Team | Recur + Memo | Bit Manipulation Made Easy | AMAZON | Leetcode-1125

Мифы о кофе

Мифы о кофе

Sum of Distances in Tree | Google | Leetcode 834 | codestorywithMIK

Sum of Distances in Tree | Google | Leetcode 834 | codestorywithMIK

This is the moment everyone has been waiting for

This is the moment everyone has been waiting for

FEDE Z 3-FUNTOWEJ ARMATY NA TWIERDZY KŁODZKO, EL CLASICO W FINALE, REAL DOŁĄCZYŁ DO BARCY

FEDE Z 3-FUNTOWEJ ARMATY NA TWIERDZY KŁODZKO, EL CLASICO W FINALE, REAL DOŁĄCZYŁ DO BARCY

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

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

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

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

Почему Андрей Карпати чувствует себя

Почему Андрей Карпати чувствует себя "отстающим" (и что это значит для вашей карьеры)

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

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

Valid Parentheses | Stack | Lecture 67

Valid Parentheses | Stack | Lecture 67

Интернет подключён, но сайты не открываются — 5 рабочих способов (Windows)

Интернет подключён, но сайты не открываются — 5 рабочих способов (Windows)

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



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



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