输入描述
输入一个字符串,都是以大写字母组成,每个相邻的距离是 1,
第二行输入一个字符串,表示必过的点。
说明每个点可过多次。
输出描述
经过这些必过点的最小距离是多少
用例
输入 | ANTSEDXQOKPUVGIFWHJLYMCRZB ABC |
输出 | 28 |
说明 | 无 |
Java
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String all = sc.nextLine();
String route = sc.nextLine();
System.out.println(getResult(all, route));
}
static Integer minLength = Integer.MAX_VALUE;
private static int getResult(String all, String route) {
HashMap<Character, List<Integer>> routeCharIndex = new HashMap<>();
HashSet<Character> routeC