Solved ValidParentheses in java