Back to course home
0% completed
Solution: Custom Sort String
Problem Statement
You are given two strings pattern
and text
. It is given that all characters of the pattern
string are unique.
Rearrange the characters of the text
string based on the characters' order in pattern
string. In other words, if a character a
occurs before a character b
in the pattern
string, then a
should occur before b
in the output string.
Characters in text
that do not appear in pattern
should be appended at the end of the rearranged string in their original order.
Examples
- Example 1:
- Input: `pattern = "xy", text = "yyzx"
.....
.....
.....
Like the course? Get enrolled and start learning!
Table of Contents
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible