@@ -0,0 +1,822 @@
+public class Solution %7B%0A    public boolean wordPattern(String pattern, String str) %7B%0A        Map%3CCharacter,String%3E patterns = new HashMap%3C%3E();%0A        String%5B%5D strs = str.split(%22 %22);%0A        if (strs.length != pattern.length()) %7B%0A            return false;%0A        %7D%0A        boolean match = true;%0A        for (int i=0; i%3Cpattern.length(); i++) %7B%0A            if (patterns.containsKey(pattern.charAt(i))) %7B%0A                if (!patterns.get(pattern.charAt(i)).equals(strs%5Bi%5D)) %7B%0A                   match = false;%0A                   break;%0A                %7D%0A            %7D else %7B%0A                if (patterns.containsValue(strs%5Bi%5D)) %7B%0A                    match = false;%0A                    break;%0A                %7D%0A                patterns.put(pattern.charAt(i), strs%5Bi%5D);%0A            %7D%0A        %7D%0A        return match;%0A    %7D%0A%7D%0A

290. Word Pattern