code: private static List<String> dedup(List<String> encoded, Map<String, Integer> nameToLastIndex) {
          boolean[] isLastInstance = new boolean[encoded.size()];
          for (int idx : nameToLastIndex.values()) {
              isLastInstance[idx] = true;
          }
          List<String> dedupd = new ArrayList<String>(nameToLastIndex.size());
          for (int i = 0, n = encoded.size(); i < n; i++) {
              if (isLastInstance[i]) {
                  dedupd.add(encoded.get(i));
              }
          }
          return dedupd;
      }
docs: Deduplicate a list of encoded cookies by keeping only the last instance with a given name.
  
  @param encoded The list of encoded cookies.
  @param nameToLastIndex A map from cookie name to index of last cookie instance.
  @return The encoded list with all but the last instance of a named cookie.