給定一個像「one two three four」這樣的句子,我將如何迭代有序排列中的單詞列表?生成給定字符串的有序排列
這就是我想要達到
"one"
"one two"
"one two three"
"one two three four"
"two"
"two three"
"two three four"
"three"
"three four"
"four"
我分裂使用空間分隔符的話,但不能工作了遍歷所有組合用文字保存在當前訂單的方法。
List<String> product_words = new ArrayList<String>(Arrays.asList(productname.split(" ")));
for (int x = 0; x < product_words.size(); x++) {
//stuck here
}
在此先感謝
這惡臭的功課。 –
@NathanielWaggoner和???? – Simon
我52歲,所以我懷疑它! – Mark