由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 面试问题求教
相关主题
大家帮忙看看我的Palindrome II 的解法leetcode里的Palindrome partition问题
请教一道面试题问个google老题的最佳解法
CC150里的1.1第二种解法哪个大牛给说说HackerRank find string..
G 家店面 找到missing number变种却看妻子愁何在,漫卷诗书喜欲狂
最长回文串不要为烙印开脱了,烙印已经骑在老中头上拉屎了
Palindrome那题,OJ上通不过为什么面试题目都答出来了还是跪了?
Palindrome那题,OJ上通不过继续攒人品 报几家面经
Facebook电话面试总结也说两个面试题
相关话题的讨论汇总
话题: string话题: s1话题: s2话题: 字符串话题: end
进入JobHunting版参与讨论
1 (共1页)
y**x
发帖数: 117
1
怎样比较两个字符串一样,除了顺序 有一个不同。 比如:
AAABB 和 ABBAA 是一样的。AB 和BA 是一样的。 就是如果头尾相接,它们是一样的。
简单的解法比如: 把第一个重复两次,然后看第二个是不是在第一里面。有其他更有
效的算法吗?
s****z
发帖数: 11
2
看了三四遍才明白问题是什么
你的解法已经是线性时间了吧
s****3
发帖数: 270
3
看不明白问题...是palindrome 还是?
b*****e
发帖数: 2511
4
如果是把string看成一个字母的集合,顺序不考虑,可以按第一个string建一个
hashmap 然后便利第二个string
y***g
发帖数: 1492
5
一帮b读不懂题目 还老有人吹老中技术牛逼 此版堪忧
o*******r
发帖数: 73
6
小白试水。
bool operator==(const string& s1, const string& s2) {
if (s1.length() != s2.length()) return false;
string tmp = s1 + s1;
string::size_type pos = tmp.find_first_of(s2);
return pos != string::npos;
}
y**x
发帖数: 117
7
就是感觉有点费内存,我重复了第一个字符串。如果字符串很大的话。
sorry for the confusion. I dont know if there is a name for this type
question.
the problem was how to check if two strings are the "same"
here the same is defined as :
the 2nd string can start from any position of the 1st string, then continue
to the end, then catch up the begin. That is: for given s1 and s2, we say s2
"same as" s1
if s2 = s1[n:end] + s1[0:n-1] where n can be any integer from 0 to end and
you certainly dont know this n.

【在 s****z 的大作中提到】
: 看了三四遍才明白问题是什么
: 你的解法已经是线性时间了吧

X***9
发帖数: 34
8
这个就是典型space v time balance
你这办法就是最优了,strstr是线性的
1 (共1页)
进入JobHunting版参与讨论
相关主题
也说两个面试题最长回文串
几道MS面试题Palindrome那题,OJ上通不过
那种对称的字符串叫什么名字Palindrome那题,OJ上通不过
攒个人品,发个google电话面试题Facebook电话面试总结
大家帮忙看看我的Palindrome II 的解法leetcode里的Palindrome partition问题
请教一道面试题问个google老题的最佳解法
CC150里的1.1第二种解法哪个大牛给说说HackerRank find string..
G 家店面 找到missing number变种却看妻子愁何在,漫卷诗书喜欲狂
相关话题的讨论汇总
话题: string话题: s1话题: s2话题: 字符串话题: end