@@ -0,0 +1,1577 @@
+/**%0A * Given a pattern and a string str, find if str follows the same pattern.%0A * Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str.%0A * Examples:%0A * pattern = %22abba%22, str = %22dog cat cat dog%22 should return true.%0A * pattern = %22abba%22, str = %22dog cat cat fish%22 should return false.%0A * pattern = %22aaaa%22, str = %22dog cat cat dog%22 should return false.%0A * pattern = %22abba%22, str = %22dog dog dog dog%22 should return false.%0A * Notes: You may assume pattern contains only lowercase letters, and str contains lowercase letters separated by a single space.%0A */%0A%0Apublic class Solution %7B%0A    public boolean wordPattern(String pattern, String str) %7B%0A        if(pattern == null %7C%7C str == null)%0A            return false;%0A        String%5B%5D string = str.split(%22 %22);%0A        if(pattern.length() != string.length)%0A            return false;%0A        Map%3CCharacter, String%3E map = new HashMap%3CCharacter, String%3E();%0A        for(int i = 0; i %3C string.length; i++) %7B%0A            char c = pattern.charAt(i);%0A            if(!map.containsKey(c))%0A                map.put(c, string%5Bi%5D);%0A            else if(!map.get(c).equals(string%5Bi%5D))%0A                return false;%0A        %7D%0A        Map%3CString, Character%3E map2 = new HashMap%3CString, Character%3E();%0A        for(int i = 0; i %3C string.length; i++) %7B%0A            String s = string%5Bi%5D;%0A            if(!map2.containsKey(s))%0A                map2.put(s, pattern.charAt(i));%0A            else if(!map2.get(s).equals(pattern.charAt(i)))%0A                return false;%0A        %7D%0A        return true;%0A    %7D%0A%7D%0A

Create 290.java