Loading...
Loading...
Loading...
Two sorted lists of ticket ids are given. Print the ids that appear in both, repeated as many times as they appear in both lists. Print none if there is no common id.
Example
Input
5 4 1 2 2 3 5 2 2 4 5
Output
2 2 5
2 appears twice in both, and 5 once.
Try the problem first. Open one hint at a time.
Use one pointer per list, as in a merge.
If the front items are equal keep one and move both pointers; otherwise move the pointer of the smaller item.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor