Given an order string and another string, reorder the second string so that characters appear in the same relative order as the order string, with any remaining characters appended at the end. The solution is driven by custom ordering, not by default alphabetic order.
order = permutation of distinct lowercase letters, s = lowercase string
string reordered by the custom order
Example 1:
Input:
order = "cba" s = "abcd"
Output:
cbad
Explanation:
Characters c, b, and a are placed first according to order.
Example 2:
Input:
order = "bcafg" s = "abcd"
Output:
bcad
Explanation:
Characters not in order are appended at the end.