Skip to content

Conversation

@sanakakadan22
Copy link

No description provided.

Copy link

@char-adadev char-adadev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 💪🏾

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants