from collections import deque
dq1 = deque([...]) # with n length
dq2 = deque([...]) # with m length
we want to left-extend dq2 to dq1 (with left to right order) and then, keep the dq1.
question1: if the best solution depends on the n and m?
I tried the following solutions:
scenario1: (n > m
)
for _ in range(len(dq2)):
dq1.appendleft(dq2.pop())
scenario2: (n < m
)
dq2.extend(dq1)
dq1 = dq2 # question2
question2: what's the time complexity of specified line? O(1)
or O(n+m)
?
question3: Are there any better solutions than these I have mentioned for 2 scenarios?