comefrom: <gouthampradhan>hashing_PartitionLabels_1.java
code: public List<Integer> partitionLabels(String S) {
      if (S == null || S.trim().isEmpty()) return new ArrayList<>();
      Map<Character, Integer> map = new HashMap<>();
      for (int i = S.length() - 1; i >= 0; i--) {
        char c = S.charAt(i);
        map.putIfAbsent(c, i);
      }
      List<Integer> result = new ArrayList<>();
      int start = 0;
      int max = map.get(S.charAt(0));
      for (int i = 0; i < S.length(); i++) {
        char c = S.charAt(i);
        if (map.get(c) > max) {
          max = map.get(c);
        } else if (i == max) {
          result.add(max - start + 1);
          if (i < S.length() - 1) {
            start = i + 1;
            max = map.get(S.charAt(i + 1));
          }
        }
      }
      return result;
    }
masked: public List < Integer > var_1 ( String var_3 ) {
    if ( var_3 == null || var_3 . trim ( ) . isEmpty ( ) ) return new ArrayList < > ( ) ;
    Map < Character , Integer > var_11 = new HashMap < > ( ) ;
    for ( int var_14 = var_3 . length ( ) - 1 ;
    var_14 >= 0 ;
    var_14 -- ) {
      char var_17 = var_3 . charAt ( var_14 ) ;
      var_11 . putIfAbsent ( var_17 , var_14 ) ;
    }
    List < Integer > var_20 = new ArrayList < > ( ) ;
    int var_21 = 0 ;
    int var_23 = var_11 . get ( var_3 . charAt ( 0 ) ) ;
    for ( int var_14 = 0 ;
    var_14 < var_3 . length ( ) ;
    var_14 ++ ) {
      char var_17 = var_3 . charAt ( var_14 ) ;
      if ( var_11 . get ( var_17 ) > var_23 ) {
        var_23 = var_11 . get ( var_17 ) ;
      }
      else if ( var_14 == var_23 ) {
        var_20 . add ( var_23 - var_21 + 1 ) ;
        if ( var_14 < var_3 . length ( ) - 1 ) {
          var_21 = var_14 + 1 ;
          var_23 = var_11 . get ( var_3 . charAt ( var_14 + 1 ) ) ;
        }
      }
    }
    return var_20 ;
  }
  