comefrom: <awangdev>Longest Valid Parentheses_3.java
code: public int longestValidParentheses(String s) {
          if (s == null || s.length() == 0) return 0;
          int n = s.length();
          Stack<Integer> stack = new Stack<>();
          char[] arr = s.toCharArray();
          for (int i = 0; i < n; i++) {
              if (arr[i] == ')' && !stack.isEmpty() && arr[stack.peek()] == '(') {
                  stack.pop();
                  continue;
              }
              stack.push(i);
          }
  
          int max = stack.isEmpty() ? n : 0;
          int end = n, start = 0;
          while (!stack.isEmpty()) {
              start = stack.pop();
              max = Math.max(max, end - start - 1);
              end = start;
          }
          return Math.max(max, end); 
      }
masked: public int sample_funcname ( String var_1 ) {
    if ( var_1 == null || var_1 . length ( ) == 0 ) return 0 ;
    int var_5 = var_1 . length ( ) ;
    Stack < Integer > var_8 = new Stack < > ( ) ;
    char [ ] var_10 = var_1 . toCharArray ( ) ;
    for ( int var_11 = 0 ;
    var_11 < var_5 ;
    var_11 ++ ) {
      if ( var_10 [ var_11 ] == ')' && ! var_8 . isEmpty ( ) && var_10 [ var_8 . peek ( ) ] == '(' ) {
        var_8 . pop ( ) ;
        continue ;
      }
      var_8 . push ( var_11 ) ;
    }
    int max = var_8 . isEmpty ( ) ? var_5 : 0 ;
    int var_19 = var_5 , var_20 = 0 ;
    while ( ! var_8 . isEmpty ( ) ) {
      var_20 = var_8 . pop ( ) ;
      max = Math . max ( max , var_19 - var_20 - 1 ) ;
      var_19 = var_20 ;
    }
    return Math . max ( max , var_19 ) ;
  }
  