

Initially, there are no usernames in the database.
Let s = {“ninjas”, “ninja”, “ninjas”, “ninjas1”}
Now In this example, first and second users are not present in the database, so they will be given the same usernames i.e. “ninjas”, “ninja”, now for the third user, “ninjas” is already present in the database, so he will be given the username “ninjas0” and for the last username, “ninjas1” is also not present in the database so he will be given the same username.
Hence the final usernames in the database will be {“ninjas”, “ninja”, “ninjas0”, “ninjas1”}.
The first line contains a single integer ‘T’ denoting the number of test cases to be run. Then the test cases follow.
The first line of each test case will be an integer ‘n’ denoting the number of users who want to register.
Next ‘n’ lines of the input will contain a string ‘s’ denoting the usernames.
For each test case, print ‘n’ strings denoting the usernames given by the website.
Output for each test case will be printed in a separate line.
You are not required to print anything; it has already been taken care of. Just implement the function and return the answer.
1 <= T <= 10
1 <= n <= 5000
1 <= |S| <= 1000, where |S| represents the length of the String S.
Time limit: 1 sec
In this approach, we will start iterating through every username and check if the current username is present in the database or not. If the current username is not present in the database then we will push it to the vector database else we will add an integer to its end.
The steps are as follows:
In this approach, we will use the trie data structure to store all the usernames which have been assigned and will check for the uniqueness of the new username using this data structure.
The steps are as follows: