Easy · Strings
Custom Sort String
Given order, a string of distinct lowercase letters, and a lowercase string s, return any permutation of s in which, whenever x comes before y in order, every x appears before every y; letters that order does not contain may be placed anywhere.
Examples
Example 1
order="cba", s="abcd"Output: "cbad"
Example 2
order="bcafg", s="abcd"Output: "bcad"
Rebuild it in the studio
Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.