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_0 ( String var_1 ) {
    if ( var_1 == null || var_1 . trim ( ) . isEmpty ( ) ) return new ArrayList < > ( ) ;
    Map < Character , Integer > var_2 = new HashMap < > ( ) ;
    for ( int var_3 = var_1 . length ( ) - 1 ;
    var_3 >= 0 ;
    var_3 -- ) {
      char var_4 = var_1 . charAt ( var_3 ) ;
      var_2 . putIfAbsent ( var_4 , var_3 ) ;
    }
    List < Integer > var_5 = new ArrayList < > ( ) ;
    int var_6 = 0 ;
    int var_7 = var_2 . get ( var_1 . charAt ( 0 ) ) ;
    for ( int var_3 = 0 ;
    var_3 < var_1 . length ( ) ;
    var_3 ++ ) {
      char var_4 = var_1 . charAt ( var_3 ) ;
      if ( var_2 . get ( var_4 ) > var_7 ) {
        var_7 = var_2 . get ( var_4 ) ;
      }
      else if ( var_3 == var_7 ) {
        var_5 . add ( var_7 - var_6 + 1 ) ;
        if ( var_3 < var_1 . length ( ) - 1 ) {
          var_6 = var_3 + 1 ;
          var_7 = var_2 . get ( var_1 . charAt ( var_3 + 1 ) ) ;
        }
      }
    }
    return var_5 ;
  }
  