comefrom: <awangdev>159. Longest Substring with At Most Two Distinct Characters_2.java
code: public int lengthOfLongestSubstringTwoDistinct(String s) {
          if (s == null || s.length() == 0) return 0;
          int n = s.length();
          Map<Character, Integer> lastOccurMap = new HashMap<>();
          int left = 0, right = 0, max = 0;
  
          while (right < n) {
              if (lastOccurMap.size() <= 2) { 
                  lastOccurMap.put(s.charAt(right), right++);
              }
              if (lastOccurMap.size() > 2) { 
                  int leftMost = right;
                  for (int index : lastOccurMap.values()) {
                      leftMost = Math.min(leftMost, index);
                  }
                  lastOccurMap.remove(s.charAt(leftMost));
                  left = leftMost + 1;
              }
              max = Math.max(max, right - left);
          }
  
          return max;
      }
masked: public int sample_funcname ( String var_1 ) {
    if ( var_1 == null || var_1 . length ( ) == 0 ) return 0 ;
    int var_5 = var_1 . length ( ) ;
    Map < Character , Integer > var_10 = new HashMap < > ( ) ;
    int var_11 = 0 , var_12 = 0 , max = 0 ;
    while ( var_12 < var_5 ) {
      if ( var_10 . size ( ) <= 2 ) {
        var_10 . put ( var_1 . charAt ( var_12 ) , var_12 ++ ) ;
      }
      if ( var_10 . size ( ) > 2 ) {
        int var_18 = var_12 ;
        for ( int var_20 : var_10 . values ( ) ) {
          var_18 = Math . min ( var_18 , var_20 ) ;
        }
        var_10 . remove ( var_1 . charAt ( var_18 ) ) ;
        var_11 = var_18 + 1 ;
      }
      max = Math . max ( max , var_12 - var_11 ) ;
    }
    return max ;
  }
  