の文字のリストに従って単語のリストを並べ替え:は、私が持っているJavaの
List<String> alphabet; (contains 26 unique characters as elements, for example
qwertyuiosapdfghjklzcxvbnm)
List<String> wordsToArrange; contains words as elements, for example:
- apple
- stream
- posthouse
- sea
- seed
私は私が作ったアルファベットに応じた単語を配置する必要があります。
私のアプローチは現時点ではサイクルのためのものです。
alphabet(i) compare it with all the words charAt(0)
if only 1 is found i put it to a new list arrangedList
but if 2 is found i go alphabet(i+1) till the letter is found and now i can put them in a right order to arrangedList....
then move back to alphabet(i+1) till alphabet(26) and now all should be arranged correctly...
私は、このコードのためのいくつかの基本を書いてきたが、私は「cyclyingのための」深刻なを開始する前に、他のアプローチがどうなるかお聞きしたかったのです。
ありがとうございます!
フォローアップ Changing specific characters in List of Strings in Java
私が正しく、それを理解していればそれだけで「qwertyuiosapdfghjklzcxvbnm」のために働くだろうが、私はすべての組み合わせの編集のために働くためにそれを必要があります。しかし、私は今、それについてより深く考えるならば、これは、インデックスとして使用するアルファベットとあれば動作します文字「 – JavaJuniorSoon2bSenior
」にマップします。 –
ありがとうございます!申し訳ありませんが、英語は私の第二の憧れです。 :) – JavaJuniorSoon2bSenior