问题描述:
解决思路:
将所有路径进行全排列,然后依次求出路径的大小,最后比较最小值,则得出最终结果
缺点:复杂度很高,不知道是否满足运行时间的条件
代码如下:
package whg.org;
import java.util.*;
import java.lang.*;
public class Whg {
public static ArrayList<String> arr = new ArrayList<String>();
public static ArrayList<Integer> dat = new ArrayList<Integer>();
public static int total = 0;
public static void swap(String[] str, int i, int j)
{
String temp = new String();
temp = str[i];
str[i] = str[j];
str[j] = temp;
}