Condition where stack is not empty This is the case where we have only opening brackets ( st . size ( ) * 2 ) will give us the total closing bracket needed cntClosing is the count of closing bracket that we already have
operationCnt += st . size ( ) * 2 - cntClosing ; return operationCnt ; }