郁闷,去微软面试,才回答一个问题就被赶出来了!# Joke - 肚皮舞运动
b*7
1 楼
Desgin an algorithm to find whether a given sting is formed by the
Intealeaving of two given strings. 注意,原来的两个given strings的本身的
character的顺序不能变。
这个题不简单,因为你不能简单的用3个指针分别指向三个string,遇到string A的就拷
贝到dst string,遇到string B的就拷贝他的。最麻烦的在于遇到A,B都相同的,你不能
advance both ptrs until they are different and then move one of them back.
The point is who is to be moved back? You cannot simply randomly choose one.
For example,
stringA: ABCEF...
string B: ABCA...
dst string : ABCABCEF....
那么,如果取B's ABCA 就错了。
哪位大侠能指教怎么
Intealeaving of two given strings. 注意,原来的两个given strings的本身的
character的顺序不能变。
这个题不简单,因为你不能简单的用3个指针分别指向三个string,遇到string A的就拷
贝到dst string,遇到string B的就拷贝他的。最麻烦的在于遇到A,B都相同的,你不能
advance both ptrs until they are different and then move one of them back.
The point is who is to be moved back? You cannot simply randomly choose one.
For example,
stringA: ABCEF...
string B: ABCA...
dst string : ABCABCEF....
那么,如果取B's ABCA 就错了。
哪位大侠能指教怎么