#791

Custom Sort String

pupil · 535 · lc medium +28 · 72.3% accepted · 3,822 likes · top 82%

Description

You are given two strings order and s. Every character in order is unique, and the characters are arranged according to a custom ordering.

Rearrange the characters of s to match the precedence defined by order. Specifically, if character x appears before character y in order, then x must appear before y in the rearranged string.

Return any valid rearrangement of s that satisfies this requirement.

Code

1
2
3