Program time limit: 1 second
Program memory limit: 512 MB
You have just landed in Quokka kingdom and Queen Quokka has given you a task - to sort a string in alphabetical order.
However, you can't sort the string in our alphabetical order, you have to sort it in their alphabetical order. You are given the order of their alphabet as input.
For all test cases:
You should read from standard input and write to standard output.
In Python, you could use the following code.
# Taking inputs, already done! :D
alphabet = input().strip()
S = input().strip()
result = ""
# Write your code here
# Printing output
print(result)
In C or C++, you could use the following code.
// Taking inputs, already done! :D
char alphabet[27]; scanf("%s", alphabet);
char S[1000001]; scanf("%s", S);
string result;
// Write your code here
// Printing output
printf("%s\n", result.c_str());
zyxwvutsrqponmlkjihgfedcba
hello
ollhe
The alphabet order is reversed (z comes first, a comes last). So when we sort "hello" according to this order, 'o' comes first (position 11), followed by 'l' (position 14), 'l' (position 14), 'h' (position 18), and 'e' (position 21). The sorted result is "ollhe".
abcdefghijklmnopqrstuvwxyz
world
dlorw
The alphabet order is the standard English alphabet (a comes first, z comes last). When we sort "world" according to this order, 'd' comes first, followed by 'l', 'o', 'r', and 'w'. The sorted result is "dlorw".
qwertyuiopasdfghjklzxcvbnm
programming
rriopaggnmm
The alphabet order is based on the QWERTY keyboard layout. When we sort "programming" according to this order, the letters are arranged as: r, r, i, o, p, a, g, g, n, m, m. The sorted result is "rriopaggnmm".
Your program will be run on both sample cases and 20 secret cases one after another, and if it produces the correct output for all test cases, it solves this task. Recall that your final score on the task is the score of your highest scoring submission.
Log in to submit!