Back to course home
0% completed
Word Pattern (easy)
Problem Statement
Given a pattern
and a string s
, return true
if the string s
follows the same pattern
.
Here, the following the pattern means each character
in the pattern should map
to a single word
in s
, and each word in s
should map to a single character
in the pattern.
Examples
Example 1:
- Input: pattern =
"eegg"
, s ="dog dog cat cat"
- Output:
true
- Explanation: The pattern "eegg" corresponds to the words "dog dog cat cat". Both 'e's map to "dog" and both 'g's map to "cat".
Example 2:
- Input: pattern =
"abca"
, s =
.....
.....
.....
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