本文共 346 字,大约阅读时间需要 1 分钟。
思路: 用一个hashMap存放已经出现的模板 单词对。。在以后出现模板的时候从hashMap里面取出单词查看是不是一样的。
public class Solution { public boolean wordPattern(String pattern, String str) { String [] strs=str.split(" "); if(strs.length!=pattern.length()) { return false; } HashMaphash=new HashMap (); for(int i=0;i
转载地址:http://fcuvb.baihongyu.com/