简体   繁体   中英

Find out all combinations without repeating the first elements - JAVA

I've defined the next ArrayList:

ArrayList<ArrayList<String>> Elements

When I fill it up it goes like this:

[[AAA, AAG], [GAA, GAG], [GUA, GUC, GUG, GUU], [UUC, UUU], [GAA, GAG], [CCA, CCC, CCG, CCU], [CAC, CAU], [UAC, UAU], [UAC, UAU]]

I need to generate all possible combinations, starting always with the first position elements of the array, which in this case are: [AAA, AAG].

fi:

AAAGAAGUAUUCGAACCACACUACUAC

AAAGAAGUAUUCGAACCACACUACUAU

AAAGAAGUAUUCGAACCACACUAUUAC

Is there any reason why:

1) Set aside the first elements of your array.

2) Generate all combinations of the remainder of your array.

3) Add back the first elements to each combination.

Does not solve your problem?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM