ReelCoding
ReelCoding
  • 261
  • 203 582
20. Valid Parentheses || LeetCode Placement Series || Explained in HINDI
Instagram link:- reelcoding
Don't click:- www.youtube.com/@reelcoding?sub_confirmation=1
Sheet link:- www.techinterviewhandbook.org/grind75?weeks=8
Approach:-
Initialize a Stack:
We use a stack to keep track of the closing parentheses expected based on the opening parentheses encountered.
Iterate through the Characters:
For each character in the string:
If it's an opening parenthesis ((, {, or [), push the corresponding closing parenthesis (), }, or ]) onto the stack.
If it's a closing parenthesis (), }, or ]), check if the stack is empty or if the top element of the stack is not the corresponding closing parenthesis. If either condition is true, the string is invalid.
Otherwise, pop the top element from the stack.
Final Check:
After iterating through all characters, the stack should be empty if the string is valid. If the stack is not empty, it means there are unmatched opening parentheses.
Time Complexity
O(n): We iterate through the string once, where n is the length of the string.
Space Complexity
O(n): In the worst case, the stack can contain all the opening parentheses, resulting in a space complexity proportional to the length of the string.
Whether you're new to problem-solving or seeking insights into Java programming techniques, this video offers valuable insights into tackling similar challenges effectively.
Do join with me guys for problem solving on LeetCode.
Please like and subscribe this channel and share among your friends, it helps me to motivate and bring more videos for you guys. ❤️❤️
Soon, DSA batch (Hinglish) is going to launch on this channel. So, do subscribe so that you will get the notification for all new videos.👍👍🔔🔔.
Do comment if any doubts left. Thank you 😊
#leetcode #computerscience #leetcodesolutions #leetcodequestionandanswers #code #learning #dsalgo #dsa
#CodingExplanation #AlgorithmTutorial #JavaProgramming #DataStructures #DynamicProgramming #CodeExplanation #ProgrammingTutorial #AlgorithmExplanation #TechTutorial #LearnToCode #ProblemSolving #ProgrammingConcepts #SoftwareDevelopment #TechEducation #CodingCommunity #CodeBreakdown #ComputerScience
#JavaTutorial #AlgorithmAnalysis #EducationalContent
20. Valid Parentheses
Leetcode 20
Valid Parentheses
Leetcode daily challenge
Leetcode potd
20 Valid Parentheses
leetcode potd today solution
leetcode potd today
leetcode grind
leetcode questions for interview
leetcode series
leetcode hindi
placement series
Переглядів: 9

Відео

1. Two Sum || LeetCode Placement Series || Explained in HINDI
Переглядів 4111 годин тому
Instagram link:- reelcoding Don't click:- www.youtube.com/@reelcoding?sub_confirmation=1 Sheet link:- www.techinterviewhandbook.org/grind75?weeks=8 Whether you're new to problem-solving or seeking insights into Java programming techniques, this video offers valuable insights into tackling similar challenges effectively. Do join with me guys for problem solving on LeetCode. Please...
Welcome to Placement Series(INTRO VIDEO) || ReelCoding || HINDI
Переглядів 582 години тому
Instagram link:- reelcoding Don't click:- www.youtube.com/@reelcoding?sub_confirmation=1 Join us as we dive deep into Data Structures and Algorithms (DSA), covering essential topics and solving a variety of problems that are frequently asked in placement interviews. Whether you're a beginner or looking to brush up on your skills, this series is designed to help you succeed. 🧠 Wha...
1636. Sort Array by Increasing Frequency || LeetCode POTD || Explained in HINDI
Переглядів 1479 годин тому
Instagram link:- reelcoding Don't click:- www.youtube.com/@reelcoding?sub_confirmation=1 Approach: Frequency Mapping: Use a HashMap to count the frequency of each element in the array. Sorting with Custom Comparator: Convert the array to an Integer array to use a custom comparator. Sort the array based on frequency. If frequencies are equal, sort by value in descending order. Rec...
2418. Sort the People || LeetCode POTD || Explained in HINDI
Переглядів 11112 годин тому
Instagram link:- reelcoding Don't click:- www.youtube.com/@reelcoding?sub_confirmation=1 Approach 1:- Map Creation: Create a HashMap to map each height to the corresponding name. Sorting Heights: Sort the heights array in ascending order. Construct Sorted Names Array: Construct the sortedNames array by iterating through the sorted heights array in reverse order (to get descending...
2392. Build a Matrix With Conditions || LeetCode POTD || Explained in HINDI
Переглядів 5514 годин тому
Instagram link:- reelcoding Don't click:- www.youtube.com/@reelcoding?sub_confirmation=1 Approach:- Graph Construction: Build two graphs, one for row conditions and another for column conditions using the buildGraph method. Topological Sorting: Perform topological sorting on both graphs to get the ordering of rows and columns using the topologicalOrder method. Matrix Construction...
1605. Find Valid Matrix Given Row and Column Sums || LeetCode POTD || Explained in HINDI
Переглядів 5916 годин тому
Instagram link:- reelcoding Don't click:- www.youtube.com/@reelcoding?sub_confirmation=1 Approach:- Initialize the Result Matrix: Create a matrix ans with dimensions based on the lengths of rowSum and colSum. Fill the Matrix: Iterate through each cell of the matrix. For each cell, set its value to the minimum of the corresponding rowSum and colSum values. Subtract the assigned va...
1380. Lucky Numbers in a Matrix || LeetCode POTD || Explained in HINDI
Переглядів 4619 годин тому
Instagram link:- reelcoding Don't click:- www.youtube.com/@reelcoding?sub_confirmation=1 Approach 1:- Matrix Traversal: Traverse each element of the matrix. For each element, determine if it is the minimum in its row and the maximum in its column. Row Minimum and Column Maximum: For each element, find the minimum value in its row. Simultaneously, find the maximum value in its col...
1530. Number of Good Leaf Nodes Pairs || LeetCode POTD || Explained in HINDI
Переглядів 4521 годину тому
Instagram link:- reelcoding Don't click:- www.youtube.com/@reelcoding?sub_confirmation=1 Approach 1: Use Depth-First Search (DFS): Perform a DFS traversal of the tree to collect distances from the leaf nodes up to their ancestors. Combine Leaf Distances: For each node, gather distances from both the left and right subtrees. Compare distances from the left and right leaf nodes to ...
1110. Delete Nodes And Return Forest || LeetCode POTD || Explained in HINDI
Переглядів 71День тому
Instagram link:- reelcoding Don't click:- www.youtube.com/@reelcoding?sub_confirmation=1 Approach: Use Depth-First Search (DFS): Perform a DFS traversal of the tree to handle the deletion process. Keep track of nodes to be deleted using a set for quick lookup. Handle Node Deletion: During the DFS traversal, if a node needs to be deleted, ensure its children are considered as new ...
2096. Step-By-Step Directions From a Binary Tree Node to Another || LeetCode POTD || HINDI
Переглядів 49День тому
Instagram link:- reelcoding Don't click:- www.youtube.com/@reelcoding?sub_confirmation=1 Approach 1:- Step 1: Find the Lowest Common Ancestor (LCA): We need to find the LCA of the two nodes. This will help us determine the common point from which both nodes can be accessed. Step 2: DFS to Record Paths: Perform DFS from the LCA to record paths to both startValue and destValue node...
2196. Create Binary Tree From Descriptions || LeetCode POTD || Explained in HINDI
Переглядів 56День тому
Instagram link:- reelcoding Don't click:- www.youtube.com/@reelcoding?sub_confirmation=1 Approach:- We'll use two maps: nodeMap: to map node values to their corresponding TreeNode objects. hasParent: to keep track of which nodes have a parent, helping us identify the root node. For each description: If a node does not exist in the nodeMap, we'll create it. We'll link the parent n...
2181. Merge Nodes in Between Zeros || LeetCode POTD || Explained in HINDI
Переглядів 4621 день тому
Instagram link:- reelcoding www.youtube.com/@reelcoding?sub_confirmation=1 Approach:- Initialization: A dummy node is created to help build the new linked list. cur pointer is used to traverse the original linked list, and newCur pointer is used to build the new linked list. Traverse and Sum: We traverse the list and calculate the sum of values between zeros. When a zero is encou...
1509. Minimum Difference Between Largest and Smallest Value in Three Moves || LeetCode POTD || HINDI
Переглядів 10421 день тому
Instagram link:- reelcoding www.youtube.com/@reelcoding?sub_confirmation=1 Approach 1:- Initialization: If the array length is less than or equal to 4, we return 0 since we can remove all elements to make the array empty. Sorting: We sort the array to simplify finding the minimum difference after removals. Calculating Minimum Difference: We consider four possible scenarios: Remov...
350. Intersection of Two Arrays II || LeetCode POTD || Explained in HINDI
Переглядів 10421 день тому
Instagram link:- reelcoding www.youtube.com/@reelcoding?sub_confirmation=1 Approach 1:- Use a HashMap to store the count of each element in the first array (nums1). Traverse the second array (nums2), and for each element, check if it exists in the HashMap and has a count greater than 0. If it does, add the element to the result list and decrement its count in the HashMap. Finally...
1550. Three Consecutive Odds || LeetCode POTD || Explained in HINDI
Переглядів 8321 день тому
1550. Three Consecutive Odds || LeetCode POTD || Explained in HINDI
1579. Remove Max Number of Edges to Keep Graph Fully Traversable || LeetCode POTD || HINDI
Переглядів 6021 день тому
1579. Remove Max Number of Edges to Keep Graph Fully Traversable || LeetCode POTD || HINDI
2192. All Ancestors of a Node in a Directed Acyclic Graph || LeetCode POTD || Explanation in HINDI
Переглядів 5528 днів тому
2192. All Ancestors of a Node in a Directed Acyclic Graph || LeetCode POTD || Explanation in HINDI
2285. Maximum Total Importance of Roads || LeetCode POTD || Explained in HINDI
Переглядів 4628 днів тому
2285. Maximum Total Importance of Roads || LeetCode POTD || Explained in HINDI
1791. Find Center of Star Graph || LeetCode POTD || Explained in HINDI
Переглядів 50Місяць тому
1791. Find Center of Star Graph || LeetCode POTD || Explained in HINDI
1382. Balance a Binary Search Tree || LeetCode POTD || Explained in HINDI
Переглядів 81Місяць тому
1382. Balance a Binary Search Tree || LeetCode POTD || Explained in HINDI
1038. Binary Search Tree to Greater Sum Tree || LeetCode POTD || Explained in HINDI
Переглядів 39Місяць тому
1038. Binary Search Tree to Greater Sum Tree || LeetCode POTD || Explained in HINDI
995. Minimum Number of K Consecutive Bit Flips || LeetCode POTD || Explained in HINDI
Переглядів 100Місяць тому
995. Minimum Number of K Consecutive Bit Flips || LeetCode POTD || Explained in HINDI
1248. Count Number of Nice Subarrays || LeetCode POTD || Explained in HINDI
Переглядів 233Місяць тому
1248. Count Number of Nice Subarrays || LeetCode POTD || Explained in HINDI
1052. Grumpy Bookstore Owner || LeetCode POTD || Explained in HINDI
Переглядів 109Місяць тому
1052. Grumpy Bookstore Owner || LeetCode POTD || Explained in HINDI
1552. Magnetic Force Between Two Balls || LeetCode POTD || Explained in HINDI
Переглядів 78Місяць тому
1552. Magnetic Force Between Two Balls || LeetCode POTD || Explained in HINDI
1482. Minimum Number of Days to Make m Bouquets || LeetCode POTD || Explained in HINDI
Переглядів 65Місяць тому
1482. Minimum Number of Days to Make m Bouquets || LeetCode POTD || Explained in HINDI
826. Most Profit Assigning Work || LeetCode POTD || Explained in HINDI
Переглядів 64Місяць тому
826. Most Profit Assigning Work || LeetCode POTD || Explained in HINDI
633. Sum of Square Numbers || LeetCode POTD || Explained in HINDI
Переглядів 40Місяць тому
633. Sum of Square Numbers || LeetCode POTD || Explained in HINDI
330. Patching Array || LeetCode POTD || Explained in HINDI
Переглядів 71Місяць тому
330. Patching Array || LeetCode POTD || Explained in HINDI

КОМЕНТАРІ

  • @reelcoding
    @reelcoding 7 годин тому

    Code link:- leetcode.com/problems/valid-parentheses/solutions/5544398/java-solution-explained-in-hindi/

  • @reelcoding
    @reelcoding 10 годин тому

    Code link:- leetcode.com/problems/two-sum/solutions/5543515/java-solution-explained-in-hindi/

  • @shardul_shorts
    @shardul_shorts День тому

    Happy Birthday bro 🎉

    • @reelcoding
      @reelcoding День тому

      Thank you so much brother ❤️

  • @harshitjaiswal2943
    @harshitjaiswal2943 День тому

    bhai please continue potd🙏

  • @SupriyaDesai101
    @SupriyaDesai101 День тому

    Omggg.. ❤ super excited for this..... ❤

  • @arihantsinghrana2173
    @arihantsinghrana2173 День тому

    Awesome Sauce!!!!!!🥳🥳

  • @reelcoding
    @reelcoding 4 дні тому

    Code link:- leetcode.com/problems/sort-array-by-increasing-frequency/solutions/5520965/java-solution-explained-in-hindi/

  • @reelcoding
    @reelcoding 5 днів тому

    Code link :- leetcode.com/problems/sort-the-people/solutions/5515732/java-solution-explained-in-hindi-2-approaches/

  • @arihantsinghrana2173
    @arihantsinghrana2173 6 днів тому

    Wow! Video quality has improved very much Great Job !!! Keep it uP!!!!

    • @reelcoding
      @reelcoding 6 днів тому

      Thank you soo much 😊

  • @reelcoding
    @reelcoding 6 днів тому

    Code link :- leetcode.com/problems/build-a-matrix-with-conditions/solutions/5510582/java-solution-explained-in-hindi/

  • @reelcoding
    @reelcoding 7 днів тому

    Code link:- leetcode.com/problems/find-valid-matrix-given-row-and-column-sums/solutions/5504438/java-solution-explained-in-hindi/

  • @reelcoding
    @reelcoding 8 днів тому

    Code link:- leetcode.com/problems/lucky-numbers-in-a-matrix/solutions/5499633/java-solution-explained-in-hindi-4-appraches/

  • @atanukundu_10
    @atanukundu_10 9 днів тому

    Thanks bro

  • @reelcoding
    @reelcoding 9 днів тому

    Code link :- leetcode.com/problems/number-of-good-leaf-nodes-pairs/solutions/5496416/java-solution-explained-in-hindi-2-approaches/

  • @devissrani1076
    @devissrani1076 10 днів тому

    Suppose i did post order traversal and upon checking every node if it's value matches any value in to_delete and I EQUATED THAT NODE TO NULL and stored its left and right into list . Why this doesn't work .........

    • @reelcoding
      @reelcoding 10 днів тому

      Equating a node to null in a post-order traversal won’t work correctly because you lose reference to its left and right children once you set the node to null.

    • @reelcoding
      @reelcoding 10 днів тому

      1.Loss of Reference:When you set a node to null, you lose the ability to access its left and right children. This is because the node itself is the reference to its children. Setting it to null means you can no longer traverse from that node to its children. 2.Incorrect Tree Structure:If you set a node to null, the tree structure becomes invalid at that point. The parent node will still hold a reference to the node you set to null, which breaks the link in the tree hierarchy. 3.Invalid Updates: During the traversal, if you try to access children of a node that has been set to null, it will lead to null pointer exceptions. The tree needs to maintain proper references between parent and child nodes to traverse correctly.

  • @reelcoding
    @reelcoding 10 днів тому

    Code link:- leetcode.com/problems/delete-nodes-and-return-forest/solutions/5489890/java-solution-explained-in-hindi/

  • @GlobeZoomers
    @GlobeZoomers 11 днів тому

    amazing video,

    • @reelcoding
      @reelcoding 11 днів тому

      Thank you so muchh 😊

  • @reelcoding
    @reelcoding 11 днів тому

    Code link:- leetcode.com/problems/step-by-step-directions-from-a-binary-tree-node-to-another/solutions/5484772/java-solution-explained-in-hindi-2-approaches/

  • @reelcoding
    @reelcoding 12 днів тому

    Code link :- leetcode.com/problems/create-binary-tree-from-descriptions/solutions/5479303/java-solution-explained-in-hindi/

  • @reelcoding
    @reelcoding 23 дні тому

    Code link:- leetcode.com/problems/merge-nodes-in-between-zeros/solutions/5413907/java-solution-explained-in-hindi/

  • @reelcoding
    @reelcoding 24 дні тому

    Code link:- leetcode.com/problems/minimum-difference-between-largest-and-smallest-value-in-three-moves/solutions/5408289/java-solution-explained-in-hindi/

  • @reelcoding
    @reelcoding 25 днів тому

    Code link:- leetcode.com/problems/intersection-of-two-arrays-ii/solutions/5400863/java-solution-explained-in-hindi-2-approaches/

  • @reelcoding
    @reelcoding 26 днів тому

    Code link:- leetcode.com/problems/three-consecutive-odds/solutions/5394812/java-solution-explained-in-hindi-3-approaches/

  • @reelcoding
    @reelcoding 27 днів тому

    Code link:- leetcode.com/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/solutions/5391610/java-solution-explained-in-hindi/

  • @reelcoding
    @reelcoding 28 днів тому

    Code link:- leetcode.com/problems/all-ancestors-of-a-node-in-a-directed-acyclic-graph/solutions/5387191/java-solution-explained-in-hindi/

  • @reelcoding
    @reelcoding 29 днів тому

    Code link:- leetcode.com/problems/maximum-total-importance-of-roads/solutions/5381519/java-solution-explained-in-hindi/

  • @sahilrajpal427
    @sahilrajpal427 Місяць тому

    I was learning prefixSum and was stuck at this particular modulo logic, thanks for clearing the concept and algo

    • @reelcoding
      @reelcoding Місяць тому

      Welcome buddy 💛

    • @sahilrajpal427
      @sahilrajpal427 Місяць тому

      @@reelcoding Dude can you suggest some subarray based 4 - 5 problems just to get proper intuition of problems related to these concepts?

    • @reelcoding
      @reelcoding 29 днів тому

      Sure you can try Leetcode 560, 713, 974, 2845

  • @reelcoding
    @reelcoding Місяць тому

    Code link:- leetcode.com/problems/find-center-of-star-graph/solutions/5376103/java-solution-explained-in-hindi/

  • @SupriyaDesai101
    @SupriyaDesai101 Місяць тому

    Short video after long long time ❤❤😢

  • @arihantsinghrana2173
    @arihantsinghrana2173 Місяць тому

    Sorted order mein lena jaroori hai kya ?? [3,2,1,null,4,null,null] ye bhi toh valid hai na ?

    • @reelcoding
      @reelcoding Місяць тому

      Haan Kyunki humein yaha balanced BST banana hai toh humein ye make sure karna hogaa ki jo elements hain humaare paas woh 2 equal half mai seperated ho jaise left part mai root se small aur right mai root se greater. Aur ek wajah hai middle element ko agar hum root consider karte hain toh ye sure ho jaata hai ki tree balance rahegi as ye baaki kaa part recursion handle karta hai left aur right subtree ko

    • @reelcoding
      @reelcoding Місяць тому

      3,2,1 ye toh yahi wrong ho gaya kyunki iskaa matlab 3 root hai aur left mai 2 aur right mai 1, (BST Condition false) iskaa order 2,1,3 honaa chahyie as 2 root node baaki left mai 1 aur right mai 3

    • @arihantsinghrana2173
      @arihantsinghrana2173 Місяць тому

      @@reelcoding mera basically doubt ye ki hume balanced tree banana hai jis mein dono sub tree ka diff less than equal to 1 hona chahiye So does it matter ki node ki values apoint karte tym sorted arraylist se hi karre ? Normal unsorted bhi chalega na kyuki ultimate goal toh balanced tree banana hai right ?

    • @reelcoding
      @reelcoding Місяць тому

      Haan humaara goal balance tree banana hai ye toh sahi hai lekin Binary Search Tree bhi toh hona chahyie iske rules bhi follow hone chahyie naa, warna woh toh normal tree ho jaayega koi saa bhi ….., question mai dekho unne keh rakha hai Balance a Binary Search Tree. Toh BST banane ke liye hi humein sorted order ki need ho rahi hai Warna hum nahi karte

    • @arihantsinghrana2173
      @arihantsinghrana2173 Місяць тому

      @@reelcoding oooh ohk I totally forgot about binary search tree part 😅 Thanks for the help broo 👍👍😁

  • @reelcoding
    @reelcoding Місяць тому

    Code link:- leetcode.com/problems/balance-a-binary-search-tree/solutions/5370767/java-solution-explained-in-hindi/

  • @SupriyaDesai101
    @SupriyaDesai101 Місяць тому

    Nicely explained! ❤❤❤

  • @reelcoding
    @reelcoding Місяць тому

    Code link :- leetcode.com/problems/binary-search-tree-to-greater-sum-tree/solutions/5366697/java-solution-explained-in-hindi-3-approaches/

  • @reelcoding
    @reelcoding Місяць тому

    Code link:- leetcode.com/problems/minimum-number-of-k-consecutive-bit-flips/solutions/5362579/java-solution-explained-in-hindi-2-approaches/

  • @reelcoding
    @reelcoding Місяць тому

    Code link :- leetcode.com/problems/count-number-of-nice-subarrays/solutions/5351381/java-solution-explained-in-hindi/ LeetCode 930 :- ua-cam.com/video/rkTDapSM_AQ/v-deo.htmlsi=bTNQ-3mhTb29ufVK

  • @anish_dalvi
    @anish_dalvi Місяць тому

    Keep Going Brother, your videos and the explanation is damn awesome 🔥 Guys Subscribe to banta hai ✅

    • @reelcoding
      @reelcoding Місяць тому

      Thankyou so much brother 💛💛

  • @SupriyaDesai101
    @SupriyaDesai101 Місяць тому

    That was a cute way of asking to Subscribe❤❤

  • @reelcoding
    @reelcoding Місяць тому

    Code link:- leetcode.com/problems/grumpy-bookstore-owner/solutions/5346090/java-solution-explained-in-hindi/

  • @SupriyaDesai101
    @SupriyaDesai101 Місяць тому

    Best! Explanation on UA-cam ❤❤❤

  • @reelcoding
    @reelcoding Місяць тому

    Code link:- leetcode.com/problems/magnetic-force-between-two-balls/solutions/5340870/java-solution-explained-in-hindi/

  • @SupriyaDesai101
    @SupriyaDesai101 Місяць тому

    Nicely explained!! ❤❤

  • @reelcoding
    @reelcoding Місяць тому

    Code link :- leetcode.com/problems/minimum-number-of-days-to-make-m-bouquets/solutions/5336414/java-solution-explained-in-hindi/

  • @SupriyaDesai101
    @SupriyaDesai101 Місяць тому

    Nice explanation...❤

  • @reelcoding
    @reelcoding Місяць тому

    Code link:- leetcode.com/problems/most-profit-assigning-work/solutions/5331947/java-solution-explained-in-hindi/

  • @reelcoding
    @reelcoding Місяць тому

    Code link :- leetcode.com/problems/sum-of-square-numbers/solutions/5326606/java-solution-explained-in-hindi-3-approaches/

  • @arihantsinghrana2173
    @arihantsinghrana2173 Місяць тому

    dheere dheere popularity bad rhi hai aapki sir !! Bataiye kesa lagg rha hai aapko !!😁😁

    • @reelcoding
      @reelcoding Місяць тому

      Popularity se jyaada mujhe ye acha lag raha ki aap log sab seekh rahe, baaki ye cheezein toh aap pe hi hai aaplog jitnaa share karoge like karoge, mujhe bhi motivation milti hai isse ❤️❤️

  • @riya25.01
    @riya25.01 Місяць тому

    nice explanation❤

  • @SupriyaDesai101
    @SupriyaDesai101 Місяць тому

    Always maintaining best video streak ❤

  • @reelcoding
    @reelcoding Місяць тому

    Code link :- leetcode.com/problems/patching-array/solutions/5322469/java-solution-explained-in-hindi/

  • @arihantsinghrana2173
    @arihantsinghrana2173 Місяць тому

    As Usual great video bro! Subha se solve karne ki kosis kar rha tha yaha tk ki intuition bhi aa chuki thi lekin I was getting stuck on how to code it..... Any suggestion for this problem of mine>> And again thanks alot this video really helped me!!

    • @reelcoding
      @reelcoding Місяць тому

      Thank you so much 😊, waise iss problem kaa ek hi solution hai jyaada se jyaada code karo bass….jitni practice hoti jaayegi utnaa brush up hotaa jaayega 💛

    • @arihantsinghrana2173
      @arihantsinghrana2173 Місяць тому

      @@reelcoding ok bro thanks again!!