Maximum Depth of Valid Nested Parentheses

Given an arithmetic expression which operators, operands and brackets. You need to find out the maximum depth of valid nested parentheses. If parentheses are not valid ( means not well formed ) then return -1.  Example: Solution: Input: 1 + (2*((3+4)/(2-1)))/2+56 Maximum Depth: 3 Input: 1 + (4/2) Maximum Depth: 1 Input: ((1)) Maximum Depth: … Read more