docs: static int execute(String source, String target) {
      if (source.length() == 0) {
        return target.length() * INSERT_COST;
      }
      if (target.length() == 0) {
        return source.length() * DELETE_COST;
      }
      int[][] table = new int[source.length()][target.length()];
      Map<Character, Integer> sourceIndexByCharacter = new HashMap<>();
      if (source.charAt(0) != target.charAt(0)) {
        table[0][0] = Math.min(REPLACE_COST, DELETE_COST + INSERT_COST);
      }
      sourceIndexByCharacter.put(source.charAt(0), 0);
      for (int i = 1; i < source.length(); i++) {
        int deleteDistance = table[i - 1][0] + DELETE_COST;
        int insertDistance = (i + 1) * DELETE_COST + INSERT_COST;
        int matchDistance = i * DELETE_COST + (source.charAt(i) == target.charAt(0) ? 0 : REPLACE_COST);
        table[i][0] = Math.min(Math.min(deleteDistance, insertDistance), matchDistance);
      }
      for (int j = 1; j < target.length(); j++) {
        int deleteDistance = (j + 1) * INSERT_COST + DELETE_COST;
        int insertDistance = table[0][j - 1] + INSERT_COST;
        int matchDistance = j * INSERT_COST + (source.charAt(0) == target.charAt(j) ? 0 : REPLACE_COST);
        table[0][j] = Math.min(Math.min(deleteDistance, insertDistance), matchDistance);
      }
      for (int i = 1; i < source.length(); i++) {
        int maxSourceLetterMatchIndex = source.charAt(i) == target.charAt(0) ? 0 : -1;
        for (int j = 1; j < target.length(); j++) {
          Integer candidateSwapIndex = sourceIndexByCharacter.get(target.charAt(j));
          int indexJSwap = maxSourceLetterMatchIndex;
          int deleteDistance = table[i - 1][j] + DELETE_COST;
          int insertDistance = table[i][j - 1] + INSERT_COST;
          int matchDistance = table[i - 1][j - 1];
          if (source.charAt(i) != target.charAt(j)) {
            matchDistance += REPLACE_COST;
          } else {
            maxSourceLetterMatchIndex = j;
          }
          int swapDistance;
          if (candidateSwapIndex != null && indexJSwap != -1) {
            int indexISwap = candidateSwapIndex;
            int preSwapCost;
            if (indexISwap == 0 && indexJSwap == 0) {
              preSwapCost = 0;
            } else {
              preSwapCost = table[Math.max(0, indexISwap - 1)][Math.max(0, indexJSwap - 1)];
            }
            swapDistance = preSwapCost + (i - indexISwap - 1) * DELETE_COST + (j - indexJSwap - 1) * INSERT_COST
              + SWAP_COST;
          } else {
            swapDistance = Integer.MAX_VALUE;
          }
          table[i][j] = Math.min(Math.min(Math.min(deleteDistance, insertDistance), matchDistance), swapDistance);
        }
        sourceIndexByCharacter.put(source.charAt(i), i);
      }
      return table[source.length() - 1][target.length() - 1];
    }