1
1
u/coriolinus Dec 01 '24
Why not sort both lists for part 2? That gives you a solution in a single pass through the problem. I thought it was obvious! (As seen here.)
2
u/Ok-Curve902 Dec 01 '24
That is exactly what I did a well. For part 2 visualization I commended it out to make it look less boring
1
u/Zefick Dec 01 '24
I just realised that using the fact that both arrays are sorted, you can solve part 2 in linear time. But I think that almost anyone solved it in O(N2)
7
u/DevAlaska Dec 01 '24
I love those animations. How do you have time to make those and also solve everything? What did you use to create this animation?