Leetcode 290: Word Pattern

Given a pattern and a string s, find if s 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 s. https://leetcode.com/problems/word-pattern/ class Solution { public boolean wordPattern(String pattern, String s) { String[] sArr = s.split(" "); Map<Character, String> map = new HashMap<>(); char[] pArr = pattern.toCharArray(); //if the length of ...

Word Pattern 1

Title: Word Pattern Source: leetcode.com 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. Examples: pattern = "abba", str = "dog cat cat dog" should return true. ...