-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGetMyList.java
More file actions
51 lines (41 loc) · 1.42 KB
/
GetMyList.java
File metadata and controls
51 lines (41 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// -------------------------------------------------------------------------
// Copyright (c) 2006-2012 GEMALTO group. All Rights Reserved.
//
// This software is the confidential and proprietary information of
// GEMALTO.
//
package algorithm;
import java.util.ArrayList;
import java.util.List;
/**
* @author <a href="mailto:[email protected]">豆SHA冰棒 </a>
* @since RM 3.0.0
*/
public class GetMyList {
private char[] patternAb;
private char chara = 'a';
private List<char[]> resList = new ArrayList<char[]>();
public static void main(String[] args) {
GetMyList obj = new GetMyList();
obj.getMyList(new char[3]);
}
public void getMyList(char[] patternAb) {
char[] tmp = new char[patternAb.length + 1];
List<Integer> indexPool = new ArrayList<Integer>();
for (int l_i = 0; l_i < tmp.length; l_i++) {
indexPool.add(l_i);
}
getMyList(tmp, (byte) 0, indexPool);
}
protected void getMyList(char[] temp, byte shift, List<Integer> indexPool) {
for (Integer i : indexPool) {
temp[i] = (char) (chara + shift);//T1
List<Integer> subIndexPool = new ArrayList<Integer>(indexPool);
subIndexPool.remove(i);//T1
if (subIndexPool.size() == 0) {
System.out.println(temp);//T1
}
getMyList(temp, (byte) (shift + 1), subIndexPool); //T(n-1)
}
}
}