For this Question: Given a string S consisting of opening and closing parenthesis '(' and ')'. Find length of the longest valid parenthesis substring.Each test case have one line string S of character '(' and ')' of length  N.

Constraints:
1 <= N <= 10^5Print the length of the longest valid parenthesis substring.Input
((()

Output
2

Input
)()())

Output
4, I have written this Solution Code: import java.io.*;
import java.util.*;



class Main {
	public static void main (String[] args) throws IOException{

					  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
					  String s = br.readLine();
					  int n = s.length();
				int left = 0, right = 0;
    int maxlength = 0;


    for(int i = 0; i < n; i++)
    {




       if (s.charAt(i) == '(')
           left++;
       else
           right++;




       if (left == right)
           maxlength = Math.max(maxlength, 2 * right);



       else if (right > left)
           left = right = 0;
    }

    left = right = 0;


    for(int i = n - 1; i >= 0; i--)
    {




       if (s.charAt(i) == '(')
           left++;
       else
           right++;




       if (left == right)
           maxlength = Math.max(maxlength, 2 * left);



       else if (left > right)
           left = right = 0;
    }
					  System.out.println(maxlength);
	}
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?