Given a pattern string consisting of lowercase English letters and a target string consisting of lowercase English letters separated by spaces, determine if there exists a bijective mapping from characters in the pattern to non-empty substrings of the target string such that replacing each character in the pattern with its mapped substring yields the target string. Each character in the pattern must map to a unique substring, and each substring must map to a unique character.
Example 1
Input: pattern=abc, target=red blue green
Output: True
Explanation: Possible mapping: a->red, b->blue, c->green.
Example 2
Input: pattern=aba, target=cat dog cat
Output: True
Explanation: Possible mapping: a->cat, b->dog.
Example 3
Input: pattern=aaa, target=dog dog dog
Output: True
Explanation: Possible mapping: a->dog.
Example 4
Input: pattern=ab, target=dog dog
Output: False
Explanation: Both pattern characters map to the same substring, violating bijection.
Constraints
Case 1
Input: pattern='xyz', target='one two three'
Expected: True
Case 2
Input: pattern='xyx', target='apple banana apple'
Expected: True
Case 3
Input: pattern='xyx', target='apple banana banana'
Expected: False
Case 4
Input: pattern='abcd', target='alpha beta gamma delta'
Expected: True
Case 5
Input: pattern='aabb', target='foo foo bar bar'
Expected: True