古茗奶茶java笔试
🤣🤣🤣🤣🤣🤣
秋后的不是第一杯奶茶,而是笔试
大编程题字典序算法
import java.util.ArrayList; public class Solution { public ArrayList<String> Permutation(String str) { ArrayList<String> ans = new ArrayList<>(); char[] chs = str.toCharArray(); int i,j,k,len; len = str.length(); ans.add(new String(chs)); for(i = len - 2; i >= 0; i--) { if(chs[i] < chs[i + 1]) { j = len - 1; while(chs[j] <= chs[i] && j > i) { j--; } char t = chs[i]; chs[i] = chs[j]; chs[j] = t; for(k = i + 1, j = len - 1; k < j; k++,j--) { t = chs[k]; chs[k] = chs[j]; chs[j] = t; } ans.add(new String(chs)); i = len -1; } } return ans; } }