educative.io

Educative

How is space complexity linear?

Merge Two Sorted Linked Lists

Given two sorted linked lists, merge them so that the resulting linked list is also sorted.

How’s the space complexity O(M+N) here?
It should O(1) right? Since we are just merging two LinkedList, we are using constant number of pointers and readjusting the LL order in place, since it’s LL. So no additional space.