Your question is Rearrangement String Match and Pattern. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Betterworks may need to validate whether a selected portion of one goal update can be rearranged to form another phrase. Given two strings, source and target, return True if characters from source can be selected and rearranged to form target; otherwise, return False.
The selected characters do not need to be contiguous, and every character in target must be matched with a distinct occurrence in source. Matching is case-sensitive, and spaces, punctuation, and digits are treated as ordinary characters.
Implement can_rearrange(source, target).
source and target.source contains at least the required frequency of every character in target.def can_rearrange(source, target):