B - Overwrite Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 8

注意

この問題に対する言及は、2020/12/27 18:00 JST まで禁止されています。言及がなされた場合、賠償が請求される可能性があります。 試験後に総合得点や認定級を公表するのは構いませんが、どの問題が解けたかなどの情報は発信しないようにお願いします。

問題文

英小文字からなる長さ N の文字列 S が与えられます。
また、文字列 T があり、 T ははじめ空文字列です。

あなたは以下の操作を i = 1, 2, \dots, N に対して、 i = 1 から順に行います。

  • S の左から i 番目の文字を c とする。 T から c と同じ文字を全て削除した後、 T の末尾に c を追加する。

操作が終わった後の T を求めてください。

制約

  • 1 \le N \le 100
  • S は英小文字からなる長さ N の文字列

入力

入力は以下の形式で標準入力から与えられる。

N
S

出力

操作が終わった後の T を出力せよ。


入力例 1

3
aba

出力例 1

ba

はじめ、 T は空文字列です。
1 回目の操作では、 T の末尾に a を追加するので a になります。
2 回目の操作では、 T の末尾に b を追加するので ab になります。
3 回目の操作では、 T から a を削除して b にした後、末尾に a を追加するので ba になります。


入力例 2

7
sptaast

出力例 2

past

入力例 3

30
ryfoxchyvfmsewlwpoyvhdjkbvdjsa

出力例 3

rxcfmelwpoyhkbvdjsa

Score : 8 points

Warning

Do not make any mention of this problem until December 27, 2020, 6:00 p.m. JST. In case of violation, compensation may be demanded. After the examination, you can reveal your total score and grade to others, but nothing more (for example, which problems you solved).

Problem Statement

Given is a string S of length N consisting of lowercase English letters.
We also have a string T, which is initially empty.

For each i = 1, 2, \dots, N in this order, you will do the following operation:

  • Let c be the i-th character from the left. Delete all occurrences of c from T, and then add c at the end of T.

Find the string T after all the operations.

Constraints

  • 1 \le N \le 100
  • S is a string of length N consisting of lowercase English letters.

Input

Input is given from Standard Input in the following format:

N
S

Output

Print the string T after all the operations.


Sample Input 1

3
aba

Sample Output 1

ba

Initially, T is empty.
In the first operation, we add a at the end of T, making it a.
In the second operation, we add b at the end of T, making it ab.
In the third operation, we delete a from T, making it b, and then add a at the end, making it ba.


Sample Input 2

7
sptaast

Sample Output 2

past

Sample Input 3

30
ryfoxchyvfmsewlwpoyvhdjkbvdjsa

Sample Output 3

rxcfmelwpoyhkbvdjsa