You are given two strings `order` and `s`. All the characters of `order` are unique and were sorted in some custom order. Permute the characters of `s` so that they match that custom order: if `x` comes before `y` in `order`, then `x` must come before `y` in the result. Characters of `s` that do not appear in `order` may go anywhere. Return any permutation of `s` that satisfies this.
You are given two strings order and s. All the characters of order are unique and were sorted in some custom order. Permute the characters of s so that they match that custom order: if x comes before y in order, then x must come before y in the result. Characters of s that do not appear in order may go anywhere. Return any permutation of s that satisfies this.
Example 1:
Input: {"order":"cba","s":"abcd"}
Output: cbad
Constraints:
1≤order.length≤26
1≤s.length≤200
order and s consist of lowercase English letters.
All the characters of order are unique.
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"order":"cba","s":"abcd"}
order "cba" ranks the letters. Tally the letters of s, then pour the bins out in that rank.