Given two sorted lists, how to find elements that appear in list1 but not in list2?

Viewed 116

I was asked this question in an interview.

For example, if given list1: 1,1,2,4,5,7 and list2: 1,3,5,8 we should return a list3: 2,4,7.

The problem requires constant space, and we need to reduce the time complexity as much as possible.

1 Answers
Related