劍指offer---字符串的排列

基於回溯法思想(排列樹): 第一次交換:字符串首字母與其他位置字母分別交換,形成多個子樹; 再第一次交換基礎上,發生第二次交換,第二次交換是字符串第二個字母與其他位置字母交換; … 直到最後一個字母結束; public ArrayList<String> Permutation(String str) { List<String> res = new ArrayList<>();
相關文章
相關標籤/搜索