题目

image.pngimage.png

解题思路

统计合格()个数

代码

  1. class Solution {
  2. public int maxDepth(String s) {
  3. int depth = 0,max =0;
  4. for(char c : s.toCharArray() ) {
  5. if(c == '(') {
  6. depth ++;
  7. }
  8. if(c == ')' ) {
  9. depth--;
  10. }
  11. max = Math.max(depth,max);
  12. }
  13. return max;
  14. }
  15. }