Checking string has balanced parentheses

后端 未结 18 2333
谎友^
谎友^ 2020-12-01 08:42

I am reading the Algorithm Design Manual Second Edition and this is from an exercise question. Quoting the question

A common problem for comp

18条回答
  •  离开以前
    2020-12-01 09:04

    Checking balanced parentheses
    package parancheck;
    
    import java.util.EmptyStackException;
    import java.util.Stack;
    
    public class ParnCheck 
    {
        public static void main(String args[])
        {
            int pu = 0;
            int po = 0;
            String str = "()())";
            System.out.println(str); 
            Stack st = new Stack();
           for(int i=0; i

提交回复
热议问题