Because the given two lists are in order, we need to look at them in a reversed order.
We can put all them in to the stack.
add them with the same way as before, and reverse it.
time: O(m + n)
space: O(m + n)
Because the given two lists are in order, we need to look at them in a reversed order.
We can put all them in to the stack.
add them with the same way as before, and reverse it.
time: O(m + n)
space: O(m + n)