Tap here to switch tabs
Problem
Ask
Submissions

Problem: Custom Sort String

med
30 min
Understand how to use hash maps to reorder a string according to a unique custom order. This lesson guides you to implement a function that returns any permutation of the input string where characters follow the specified sequence from the custom order, helping you apply hash map concepts in solving string manipulation problems.

Statement

Given two strings, order and s, where all characters in order are unique and arranged in a custom order, return any permutation of s that satisfies the following condition:

The characters in the permuted s should appear in the same relative order as they do in order. Specifically, if a character x appears before a character y in order, then x must also appear before y in the permuted string.

Constraints:

  • 11 \leq order.length 26\leq 26

  • 11 \leq s.length 200\leq 200

  • order and s consist of lowercase English letters.

  • All the characters of order are unique.

Tap here to switch tabs
Problem
Ask
Submissions

Problem: Custom Sort String

med
30 min
Understand how to use hash maps to reorder a string according to a unique custom order. This lesson guides you to implement a function that returns any permutation of the input string where characters follow the specified sequence from the custom order, helping you apply hash map concepts in solving string manipulation problems.

Statement

Given two strings, order and s, where all characters in order are unique and arranged in a custom order, return any permutation of s that satisfies the following condition:

The characters in the permuted s should appear in the same relative order as they do in order. Specifically, if a character x appears before a character y in order, then x must also appear before y in the permuted string.

Constraints:

  • 11 \leq order.length 26\leq 26

  • 11 \leq s.length 200\leq 200

  • order and s consist of lowercase English letters.

  • All the characters of order are unique.