• + 0 comments

    Let take this example: {}}}{} 1.Value inserted into Old stack : bottom[ {,},},},{,} ]top 2.Now it will pop first element i.e. “}” 3.Since it satisfy this condition : if(popElement.contains("}") || popElement.contains(")") || popElement.contains("]”)) This value “}” will be pushed in newStack New Stack : bottom[ } ]top 4.Now it will pop second element i.e. “{“ Since it satisfy this condition /*else{ String popElementPair = hMap.get(popElement); String popElementNewStack = newStack.pop(); if(popElementPair.equals(popElementNewStack)){ casePass=true; }else{ casePass=false; } } */ 5.Now this key:”{“ has value “}”, so i will pop value “}" from new stack. Old stack : bottom[ {,},},} ]top ; New Stack : bottom[ ]top 6.This goes on in loop 7.In the end situation will be Old stack : bottom[ ]top New Stack : bottom[ },} ]top And case will get failed since new stack is not empty.