


S= “https://youtu.be/dQw4w9WgXcQ”, can be encoded to TinyUrl “http://tinyurl.com/abcdef”, then in future queries “http://tinyurl.com/abcdef” can be decoded into “https://youtu.be/dQw4w9WgXcQ”
The URL given to you for decoding will always be one of the URLs you have already returned after encoding in the past.
The encoded URL should strictly be of the format “http://tinyurl.com/abcdef”, where instead of “abcdef” you can have any alphanumeric code of length 6.
The first line contains an integer, 'K’ denoting the number of queries.
The second line contains a string ‘S’, denoting the URL.
For each test case, return the decoded URL.
Output for each test case should be in a new line.
You don't print anything, it has already been taken care of. Just implement the given functions.
1 <= K <= 1000
1 <= |S| <= 50
Where |S| is the length of string S.
Time Limit: 1 sec
Encoding :
Encoding a URL into TinyURL “http://tinyurl.com/abcdef”, where “abcdef” is an alphanumeric string of length 6, can be done using a simple hashing algorithm, and an alphanumeric string generator.
For an alphanumeric string generator, you can just generate a random alphanumeric string of length 6 and check whether this code is previously used or not. If it isn’t then use it to encode the current URL.
Decoding:
After encoding the URL in the encoding function, you are to hash the original string to TinyURL. Which you can use in the decoding function.
Below is the detailed algorithm:
Encode function:
Decode function: