我觉得这本书可以当做小说来看了,如果是一眼就能看出答案的题目(哪怕可能有更tricky的方法)我就先跳过。
1.1 确定字符互异
可用set等方式。难度0。
1.2 原串翻转
可用stack等方式。难度0。
1.3 确定两串乱序同构
可用sort,set之类。难度0。
1.4 空格替换
送分题。难度0。
1.5 基本字符串压缩
记录一下次数就行。
1.6 像素翻转
普通的数组操作吧。
1.7 清除行列
普通的数组操作吧。
1.8 翻转子串
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”)
这题没想出来,一开始感觉不太可能只调用一次啊,该不会是递归调吧。后来发现之前旁边实习生跟我说的链表那题一个套路,涉及rotation就用拼接。
网友评论