当前位置:网站首页>Full Permutation Code (recursive writing)
Full Permutation Code (recursive writing)
2022-07-05 05:38:00 【Java full stack R & D Alliance】
The code is as follows :
public static List<String> getSubstring(String[] words) {
if(words.length==1){
return Arrays.asList(words);
}
List<String> resultList = new ArrayList<>();
for (int i = 0; i < words.length; i++) {
String[] strings = Arrays.copyOf(words, words.length);
strings = changeArray(strings, i);
List<String> stringList = getSubstring(strings);
for (String str : stringList) {
resultList.add(words[i] + str);
}
}
return resultList;
}
public static String[] changeArray(String[] words, int i) {
for (int k = i; k < words.length - 1; k++) {
words[k] = words[k + 1];
}
return Arrays.copyOf(words, words.length - 1);
}
If you test
String[] words = {
"1", "2", "3"};
List<String> substring = getSubstring(words);
System.out.println(substring);
Print the results :
边栏推荐
- Haut OJ 1218: maximum continuous sub segment sum
- Bit mask of bit operation
- Zheng Qing 21 ACM is fun. (3) part of the problem solution and summary
- SAP-修改系统表数据的方法
- 每日一题-无重复字符的最长子串
- Sword finger offer 05 Replace spaces
- Pointnet++学习
- Educational codeforces round 109 (rated for Div. 2) C. robot collisions D. armchairs
- Warning using room database: schema export directory is not provided to the annotation processor so we cannot export
- Animation scoring data analysis and visualization and it industry recruitment data analysis and visualization
猜你喜欢

Remote upgrade afraid of cutting beard? Explain FOTA safety upgrade in detail

A new micro ORM open source framework

Implement a fixed capacity stack

YOLOv5-Shufflenetv2

剑指 Offer 09. 用两个栈实现队列

Educational Codeforces Round 116 (Rated for Div. 2) E. Arena

Graduation project of game mall

第六章 数据流建模—课后习题

lxml.etree.XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8

API related to TCP connection
随机推荐
Solution to the palindrome string (Luogu p5041 haoi2009)
ALU逻辑运算单元
Haut OJ 1357: lunch question (I) -- high precision multiplication
Zzulioj 1673: b: clever characters???
Sword finger offer 09 Implementing queues with two stacks
kubeadm系列-02-kubelet的配置和启动
kubeadm系列-01-preflight究竟有多少check
[article de jailhouse] jailhouse hypervisor
剑指 Offer 53 - II. 0~n-1中缺失的数字
剑指 Offer 53 - I. 在排序数组中查找数字 I
Light a light with stm32
二十六、文件系统API(设备在应用间的共享;目录和文件API)
Educational Codeforces Round 116 (Rated for Div. 2) E. Arena
Fried chicken nuggets and fifa22
剑指 Offer 04. 二维数组中的查找
全国中职网络安全B模块之国赛题远程代码执行渗透测试 //PHPstudy的后门漏洞分析
Drawing dynamic 3D circle with pure C language
kubeadm系列-00-overview
Educational codeforces round 109 (rated for Div. 2) C. robot collisions D. armchairs
Acwing 4300. Two operations