题解 | #括号匹配深度#
括号匹配深度
http://www.nowcoder.com/practice/a2d5b1875bb0408384278f40d1f236c9
import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); String s=sc.nextLine(); int count=0,res=0; for(int i=0;i<s.length();i++){ if(s.charAt(i)=='('){ count++; }else{ count--; } res=Math.max(res,count); } sc.close(); System.out.println(res); } }