The time complexity is O(n + m), where n and m are the lengths of the two lists, because each element from both lists is visited at most once.
The space complexity is O(1), as we only use a fixed number of extra pointers, regardless of the input list sizes.