Sort 254 Discussions, By:
Please Login in order to post a comment
The test cases of this one are absolutely evil. Every string is so long that it is difficult to find out what is going wrong. I would suggest making some test cases with some smaller strings which cover all the cases anybody may overlook and only have some cases which test running times.
If you passed only the first half of the test cases like I did, and can't tell why, here's the secret: You need to throw a 'z' on the end of both input strings.
This is definitely one of the worst designed challenges so far. The instructions are vague, the example input and output are easily passed while every other test case fails, and the test cases themselves are all too large to reason with and figure out errors. There is a much more clever and 'right' solution involving suffix arrays, but again, the instructions are vague and never mention a word about them, which discourages research of the topic.
My suggestion to the problem author is to go over expected logic when letters are equal, because that is where people will struggle with understanding the expectation.
A = ABA ( 012 )
B = ABAA ( 3456 )
, the editorial code gives ans -> AABABAA ( 0312456 ), but the correct one I think is AABAABA ( 3045612 ) . It's mine mistake or ?????
def morgan(a, b):
a += 'z'
b += 'z'
for _ in range(len(a) + len(b) - 2):
if a < b:
a = a[1:]
b = b[1:]
def morganAndString(a, b):
return ''.join(morgan(a, b))
Very poorly worded problem. When you read it, it looks like a merge sort when you can only look at top values. And apparently it's not the case. You learn it when you fail all test cases but example one. You'll need look-ahead in this one which is completely in contradiction to what one would understand "you can only take from top of the collection".