comefrom: <awangdev>159. Longest Substring with At Most Two Distinct Characters_1.java
code: public int lengthOfLongestSubstringTwoDistinct(String s) {
          if (s == null)  return 0;
          int left = 0, right = 0, max = 0, n = s.length();
          Map<Character, Integer> freq = new HashMap<>();
  
          while (right < n) {
              char head = s.charAt(right++);
              freq.put(head, freq.getOrDefault(head, 0) + 1);
              
              if (freq.size() <= 2) max = Math.max(max, right - left);
              
              if (freq.size() > 2) {
                  char tail = s.charAt(left++);
                  freq.put(tail, freq.get(tail) - 1);
                  if (freq.get(tail) == 0) freq.remove(tail);
              }
          }
          
          return max;
      }
masked: public int sample_funcname ( String var_1 ) {
    if ( var_1 == null ) return 0 ;
    int var_4 = 0 , var_5 = 0 , max = 0 , var_8 = var_1 . length ( ) ;
    Map < Character , Integer > var_13 = new HashMap < > ( ) ;
    while ( var_5 < var_8 ) {
      char var_15 = var_1 . charAt ( var_5 ++ ) ;
      var_13 . put ( var_15 , var_13 . getOrDefault ( var_15 , 0 ) + 1 ) ;
      if ( var_13 . size ( ) <= 2 ) max = Math . max ( max , var_5 - var_4 ) ;
      if ( var_13 . size ( ) > 2 ) {
        char var_22 = var_1 . charAt ( var_4 ++ ) ;
        var_13 . put ( var_22 , var_13 . get ( var_22 ) - 1 ) ;
        if ( var_13 . get ( var_22 ) == 0 ) var_13 . remove ( var_22 ) ;
      }
    }
    return max ;
  }
  