Testsigma Interview Question

Max sum from the sub array,valid paranthasis