Hey all.
Im trying to get this right. Please correct me if my understanding is right or if your agree.
I think the following code has
Im trying to get this right. Please correct me if my understanding is right or if your agree.
I think the following code has
time complexity
of O(1)
and a space complexity
of O(n)
. Do you agree?def zigzag(str1, str2): minum = min(len(str1), len(str2)) output = [None] * minum * 2 output[::2] = str1[:minum] output[1::2] = str2[:minum] return ''.join(output) + str1[minum::] + str2[minum::] def main(): str1 = "abcdefgh" str2 = "1111" print(zigzag(str1, str2)) if __name__ == "__main__": main()