LeetCode – Word Pattern (Java)
Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str. Java Solution public boolean wordPattern(String pattern, String str) { String[] arr = str.split(" "); //prevent out of … Read more