package careerCup;

import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.Stack;

/*
 * Link: http://www.geeksforgeeks.org/length-of-the-longest-valid-substring/
 */
public class _03googleCareerCup {

	public static void main(String[] args) {
		Scanner scanner=new Scanner(new InputStreamReader(System.in));
		String inputString=scanner.nextLine();
		scanner.close();
		System.out.println(findLength(inputString));
	}

	private static char[] findLength(String inputString) {
		Stack<Character> charStack=new Stack<Character>();
		for (int i = 0; i < inputString.length(); i++) {
			
		}
		
		return null;
	}
}

@@ -473,14 +473,11 @@
 tic 
-char%5B%5D
+int
  fin
@@ -561,16 +561,43 @@
 er%3E();%0D%0A
+%09%09int count=0,maxCount=0;%0D%0A
 %09%09for (i
@@ -647,32 +647,365 @@
 %0A%09%09%09
-%0D%0A%09%09%7D%0D%0A%09%09%0D%0A%09%09return null
+char element=inputString.charAt(i);%0D%0A%09%09%09if(element=='(')%0D%0A%09%09%09%09charStack.push(element);%0D%0A%09%09%09else%7B%0D%0A%09%09%09%09if(!charStack.isEmpty() && charStack.pop()=='(')%0D%0A%09%09%09%09%7B%0D%0A%09%09%09%09%09count+=2;%0D%0A%09%09%09%09%7D%0D%0A%09%09%09%09else%7B%0D%0A%09%09%09%09%09charStack=new Stack%3CCharacter%3E();%0D%0A%09%09%09%09%09if(count%3EmaxCount)%0D%0A%09%09%09%09%09%09maxCount=count;%0D%0A%09%09%09%09%09count=0;%0D%0A%09%09%09%09%7D%0D%0A%09%09%09%7D%0D%0A%09%09%09%0D%0A%09%09%7D%0D%0A%09%09return count%3EmaxCount?count:maxCount
 ;%0D%0A%09

Longest valid substring completed