CRCK array 1.8
2016-03-27 06:07
288 查看
Assume you have a method isSubstring which checks if one word is a substring of another. Given two strings, s1 and s2, write code to check if s2 is a rotation of s1 using only one call to isSubstring (i.e., “waterbottle” is a rotation of “erbottlewat”).
// Nothing difficult on this problem. // supposed the input is ""waterbottle", its rotation is "erbottlewat" // example: rotation + rotation = erbottles"waterbottle"wat. bool checkRotation(string s1, string s2) { string s3 = s2 + s2; return isSubstring(s1, s3); }
相关文章推荐
- 已解决的问题——Application package 'AndroidManifest.xml' must have a minimum of 2 segments.
- myeclipse/eclipse修改JSP生成模板pageEncoding为UTF-8
- LeetCode House Robber III
- ReentrantReadWriteLock读写锁的使用
- 使用Thrift RPC编写程序
- 313. Super Ugly Number
- [leetcode] 134. Gas Station 解题报告
- emacs使用http代理打开
- u-boot分析 六 (从code flow看u-boot到kernel的启动过程)
- Android图形graphics
- LeetCode Two Sum II - Input array is sorted
- 神经网络对比
- LeetCode Two Sum III - Data structure design
- flume介绍以及环境的部署
- Factory Method
- (PHP+HTML+JavaScript+Css)一个简单爬虫的开发
- MindNode Pro serial number
- incompatible with sql_mode=only_full_group_by
- Scss sass
- A Deeper Look at the Scala Syntax (scala block)