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_0 , String var_1 , String var_2 ) {
    Map < String , List < Integer >> var_3 = new HashMap < > ( ) ;
    for ( int var_4 = 0 ;
    var_4 < var_0 . length ;
    var_4 ++ ) {
      var_3 . putIfAbsent ( var_0 [ var_4 ] , new ArrayList < > ( ) ) ;
      var_3 . get ( var_0 [ var_4 ] ) . add ( var_4 ) ;
    }
    List < Integer > var_5 = var_3 . get ( var_1 ) , var_6 = var_3 . get ( var_2 ) ;
    int min = Integer . MAX_VALUE ;
    int var_4 = 0 , var_7 = 0 , var_8 = var_5 . size ( ) , var_9 = var_6 . size ( ) ;
    while ( var_4 < var_8 && var_7 < var_9 ) {
      int var_10 = var_5 . get ( var_4 ) , var_11 = var_6 . get ( var_7 ) ;
      if ( var_10 == var_11 ) {
        if ( var_4 + 1 < var_8 ) var_4 ++ ;
        else if ( var_7 + 1 <= var_9 ) var_7 ++ ;
        continue ;
      }
      min = Math . min ( min , Math . abs ( var_10 - var_11 ) ) ;
      if ( var_10 < var_11 ) var_4 ++ ;
      else var_7 ++ ;
    }
    return min ;
  }
  