前書き
次の文字列を観察してみましょう。
AABBCCDDEFFGG
手紙を除いて、すべての手紙が複製されていることがわかりE
ます。それは、手紙E
が重複していないことを意味します。したがって、ここで行う必要があるのは、そのプロセスを逆にすることだけです。これにより、次の重複のない文字列が得られます。
AABBCCDDEEFFGG
もっと難しい例を見てみましょう。
AAAABBBCCCCDD
連続したB
の数が不均一であることがわかりBB
ます。つまり、元の文字列の1つが重複していないことを意味します。この手紙の重複を取り消すだけで、次のことができます。
AAAABBBBCCCCDD
チャレンジ
空でない所与の重複除外で構成される文字列、英字のみ(どちらかのみ大文字または小文字のみ)、戻り非重複除外文字列。文字列には少なくとも1つの重複排除された文字が常に存在すると想定できます。
テストケース
AAABBBCCCCDDDD --> AAAABBBBCCCCDDDD
HEY --> HHEEYY
AAAAAAA --> AAAAAAAA
N --> NN
OOQQO --> OOQQOO
ABBB --> AABBBB
ABBA --> AABBAA
これはcode-golfであるため、バイト単位の最短の有効な送信が優先されます!
ABBB
マッピングしAABBBB
ないのはなぜAABBBBBB
ですか?
A BB B
。ペアになっていない(したがって複製されていない)文字を複製する必要があります。その結果、AA BB BB
重複しない文字列がになります。
AABBBB
ます。