Practice Custom Sort String
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You are given two strings order and s. All the characters of order are unique and were sorted in some custom order previously. Permute the characters of s so that they match the order that order was sorted. More specifically, if a character x occurs before a character y in order, then x should occur before y in the permuted string. Return any permutation of s that satisfies this property.
Source: Custom Sort String on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
order = "cba", s = "abcd"
"cbad"
# Example 2
order = "bcafg", s = "abcd"
"bcad"
Constraints
Related LeetCode Problems
Practice more problems similar to Custom Sort String.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.