Package g0201_0300.s0290_word_pattern
Class Solution
java.lang.Object
g0201_0300.s0290_word_pattern.Solution
290 - Word Pattern.<p>Easy</p>
<p>Given a <code>pattern</code> and a string <code>s</code>, find if <code>s</code> follows the same pattern.</p>
<p>Here <strong>follow</strong> means a full match, such that there is a bijection between a letter in <code>pattern</code> and a <strong>non-empty</strong> word in <code>s</code>.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> pattern = “abba”, s = “dog cat cat dog”</p>
<p><strong>Output:</strong> true</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> pattern = “abba”, s = “dog cat cat fish”</p>
<p><strong>Output:</strong> false</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> pattern = “aaaa”, s = “dog cat cat dog”</p>
<p><strong>Output:</strong> false</p>
<p><strong>Example 4:</strong></p>
<p><strong>Input:</strong> pattern = “abba”, s = “dog dog dog dog”</p>
<p><strong>Output:</strong> false</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= pattern.length <= 300</code></li>
<li><code>pattern</code> contains only lower-case English letters.</li>
<li><code>1 <= s.length <= 3000</code></li>
<li><code>s</code> contains only lower-case English letters and spaces <code>' '</code>.</li>
<li><code>s</code> <strong>does not contain</strong> any leading or trailing spaces.</li>
<li>All the words in <code>s</code> are separated by a <strong>single space</strong>.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
wordPattern
-