ArrayList<ArrayList<ArrayList<String>>> one = new ArrayList<ArrayList<ArrayList<String>>>();
one
看起来像这样带有一些示例值:
[
[
["A","B","C",...],
["G","E","J",...],
...
],
[
["1","2",...],
["8","5","12","7",...],
...
],
...
]
假设总会有一种基本情况,至少有一个字母数组列表(例如 ["A","B","C"]),但可能会有更多(例如 ["X,"Y","Z" ]) 并且可能有任何大小的数组列表,可能根本没有,但可能是数百个(例如 ["1","2","3"],...,["997","998", “999”])。此外,可能有更多类型的任意大小的数组列表(例如 ["@","#","$"])。所以真正唯一确定的是始终:
one.size()>=1
one.get(0).size()>=1
one.get(0).get(0).size()>=1
所以问题是:在不知道每个数组列表有多大或有任何重复但假设 one.get(0).get(0) 有效的情况下,如何最好地获得每个类别的每个组合?例如["A","B","C",...] ["1","2",...] ...
,["A","B","C",...] ["8","5","12","7",...] ...
。我目前在我的项目中使用 Java,但是任何有效的算法我都可以自己转换。如果不清楚,我深表歉意,我很难用语言表达,这可能是我想不出解决方案的部分原因。