标签:
public class Solution { public boolean wordPattern(String pattern, String str) { String[] s=str.split(" "); if(pattern.length()!=s.length) return false; for(int i=0;i<pattern.length();i++) { for(int j=0;j<i;j++) { if((pattern.charAt(i)!=pattern.charAt(j)&&s[i].equals(s[j]))|(pattern.charAt(i)==pattern.charAt(j)&&!s[i].equals(s[j]))) return false; } } return true; } }
啊啊啊,真的没啥东西好写啊【leetcode】290. Word Pattern
标签:
原文地址:http://www.cnblogs.com/dyuxuan/p/4872151.html