Balanced Parenthesis using Stack

Поделиться
HTML-код
  • Опубликовано: 7 фев 2025
  • This video describes how to implement an application of Stack - Balanced Parentheses
    The following links are for reference:
    www.geeksforge...
    github.com/Shi...

Комментарии • 18

  • @mukulanand8807
    @mukulanand8807 Год назад +2

    Thanks in advance, now I am going to watch your video..

  • @SherpaBros
    @SherpaBros 4 года назад +2

    😃So nice OMG

  • @RohitChaurasiyalisten
    @RohitChaurasiyalisten 4 года назад +2

    This is more clear and better way.
    package com.rohit.demo;
    import java.util.ArrayDeque;
    import java.util.Deque;
    public class Balanced {
    public static boolean balanced(String exp) {
    Deque stack = new ArrayDeque();
    for (int i = 0; i < exp.length(); i++) {
    char x = exp.charAt(i);
    if (x == '(' || x == '{' || x == '[') {
    stack.push(x);
    continue;
    }
    if(stack.isEmpty())
    return false;
    stack.pop();
    }
    if (stack.isEmpty())
    return true;
    return false;
    }
    public static void main(String args[]) {
    String expr = "))(({}{";
    System.out.println(balanced(expr));
    }
    }

  • @BeTheOnex
    @BeTheOnex 5 лет назад

    Mam kamal ka ap ny samjhaya hai❤❤❤❤❤❤❤❤❤❤

  • @subashchandrapakhrin3537
    @subashchandrapakhrin3537 4 года назад +1

    You have tried your best but your explanation is not good one matching pair(st.pop().exp[i] what??

  • @edgarcalochcampos1930
    @edgarcalochcampos1930 5 лет назад +1

    why do we return st.pop() as an argument of isMatchingPair function?

  • @niyomungelialine6840
    @niyomungelialine6840 Год назад

    not clear about ismaching
    ???

  • @vaishakhsz
    @vaishakhsz Год назад

    7th line it should be (!st.empty()) i guess, as when the stack becomes empty it should return true, whereas here its false

  • @anubhcools8053
    @anubhcools8053 4 года назад

    nice shivangi

  • @TargetCGL9
    @TargetCGL9 3 года назад +1

    Code for matching function

  • @neerajtadhiyal3152
    @neerajtadhiyal3152 3 года назад +1

    Plzzz do answer my question . that isMachingPare merhode is made by you ou it is predifend. if it is predefined then in which package . cuz I cant find it in Java.util package .

    • @muhammadwasi5460
      @muhammadwasi5460 3 года назад

      it's in c++ .. It is a library you have to include #include

  • @BeTheOnex
    @BeTheOnex 5 лет назад +1

    Mam make more videos on data structures plz

  • @nishisingh5160
    @nishisingh5160 4 года назад +1

    would you provide the code

  • @roshanrajkumar7827
    @roshanrajkumar7827 4 года назад +1

    2nd year??

  • @ManalShyhzad
    @ManalShyhzad 3 месяца назад

    Everyone on youtube is literally explaining the procedure but very few of them focuses on explaining the code unfortunately according to me you are not one of them, you video ws not worth watching