comefrom: <awangdev>245. Shortest Word Distance III_2.java
code: public int shortestWordDistance(String[] words, String word1, String word2) {
          Map<String, List<Integer>> map = new HashMap<>();
          for (int i = 0; i < words.length; i++) {
              map.putIfAbsent(words[i], new ArrayList<>());
              map.get(words[i]).add(i);
          }
          
          List<Integer> list1 = map.get(word1), list2 = map.get(word2);
          int min = Integer.MAX_VALUE;
          int i = 0, j = 0, m = list1.size(), n = list2.size();
          while (i < m && j < n) {
              int p1 = list1.get(i), p2 = list2.get(j);
              if (p1 == p2) { 
                  if (i + 1 < m) i++;
                  else if (j + 1 <= n) j++; 
                  continue;
              }
              min = Math.min(min, Math.abs(p1 - p2));
              if (p1 < p2) i++; 
              else j++;
          }
          return min;
      }
masked: public int sample_funcname ( String [ ] var_1 , String var_2 , String var_3 ) {
    Map < String , List < Integer >> var_8 = new HashMap < > ( ) ;
    for ( int var_10 = 0 ;
    var_10 < var_1 . length ;
    var_10 ++ ) {
      var_8 . putIfAbsent ( var_1 [ var_10 ] , new ArrayList < > ( ) ) ;
      var_8 . get ( var_1 [ var_10 ] ) . add ( var_10 ) ;
    }
    List < Integer > var_16 = var_8 . get ( var_2 ) , var_17 = var_8 . get ( var_3 ) ;
    int min = Integer . MAX_VALUE ;
    int var_10 = 0 , var_20 = 0 , var_22 = var_16 . size ( ) , var_23 = var_17 . size ( ) ;
    while ( var_10 < var_22 && var_20 < var_23 ) {
      int var_24 = var_16 . get ( var_10 ) , var_25 = var_17 . get ( var_20 ) ;
      if ( var_24 == var_25 ) {
        if ( var_10 + 1 < var_22 ) var_10 ++ ;
        else if ( var_20 + 1 <= var_23 ) var_20 ++ ;
        continue ;
      }
      min = Math . min ( min , Math . abs ( var_24 - var_25 ) ) ;
      if ( var_24 < var_25 ) var_10 ++ ;
      else var_20 ++ ;
    }
    return min ;
  }
  