古茗奶茶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;
       
    }
}


#java工程师##笔经#
全部评论
楼主最后去了吗
点赞 回复 分享
发布于 2022-07-18 10:11

相关推荐

小浪_Coding:找硬件测试,也可兼顾软测欧, 简历还可以的 ,注意排版,项目写的有条理一点, 然后个人技能多加点, 润色好简历之后就开始沟通海投了,深圳,东莞这边做硬件相关的公司还不少, 医疗类,仪器类的都可以尝试
点赞 评论 收藏
分享
07-15 11:43
门头沟学院 Java
点赞 评论 收藏
分享
评论
4
6
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务