Sana Pournaghshband - Sharks - Section A#87
Sana Pournaghshband - Sharks - Section A#87sanakakadan22 wants to merge 1 commit intoada-c17:mainfrom
Conversation
char-adadev
left a comment
There was a problem hiding this comment.
Excellent work and implementation here. I love the use of the hashset. You're also spot on with your space and time complexity here.
If you did want a solution that had the same time complexity but with O(1) space, you could technically loop through each list until one of them reaches the end. Once one of them reaches the end, you can re-assign that pointer to be the head of the other list (e.g. using two variables, currA and currB to follow the lists, checking their equality along the way, and then once currA hits None, reassigning it to be headB).
Your solution is great on its own and would be an excellent choice while doing an interview, the above suggestion is purely for an alternative approach and can be used as a thought experiment.
Strong work 💪🏾
No description provided.