33.Word Pattern
2015-10-20 21:47
260 查看
Given a
find if
Here follow means a full match, such that there is a bijection between a letter in
a non-empty word in
Examples:
pattern =
pattern =
pattern =
pattern =
Notes:
You may assume
lowercase letters separated by a single space.
分析:
1.用map存储字符与字符串间的对应关系
2.如果map中已经存了这个字符,则判断当前value与map中存的oldvalue是否相同,不相同则返回false,相同则继续。
3.如果map中尚未存了这个字符,但是已经有了这个value,则返回false。否则加入<key,value>
patternand a string
str,
find if
strfollows the same pattern.
Here follow means a full match, such that there is a bijection between a letter in
patternand
a non-empty word in
str.
Examples:
pattern =
"abba", str =
"dog cat cat dog"should return true.
pattern =
"abba", str =
"dog cat cat fish"should return false.
pattern =
"aaaa", str =
"dog cat cat dog"should return false.
pattern =
"abba", str =
"dog dog dog dog"should return false.
Notes:
You may assume
patterncontains only lowercase letters, and
strcontains
lowercase letters separated by a single space.
分析:
1.用map存储字符与字符串间的对应关系
2.如果map中已经存了这个字符,则判断当前value与map中存的oldvalue是否相同,不相同则返回false,相同则继续。
3.如果map中尚未存了这个字符,但是已经有了这个value,则返回false。否则加入<key,value>
相关文章推荐
- Vim中的查找和替换
- Node之锚点
- 安装rackspace private cloud --2 overview
- JavaScript学习随记——数组二
- 深度优先遍历之边的分类
- 程序员既要写好代码,又要写好文档
- 面试题40:数组中只出现一次的数字
- iOS改变UIImageView的image时添加渐变
- srm 552
- eclipse或myeclipse常用配置和快捷键
- hp-unix 根盘镜像及镜像解除
- 引入内联函数的目的和作用
- think in UML(二)
- 前端开发梦中景象
- 从c到c++<四>
- 线性回归相关知识
- sizeof使用的相关总结
- 找出数组中重复次数为2的元素,
- ListView实现Item局部刷新
- IO多路复用 epoll模型