Given two linked lists, head1 and head2, identify the intersection of the two lists. Both linked lists have unique node values with no duplicates.
Note: The nodes in the resulting list should maintain the same order as they appear in the input list head1. If there are no common elements between the two lists, return null.
Topics
Companies
Articles
Examples:
Expected Time Complexity: O(m+n)
Expected Space Complexity: O(m+n)
Constraints:
1 <= no. of nodes in head1, head2 <= 10^4
1 <= node->data <= 10^5
Companies:
AmazonMicrosoftVisaFlipkart
Topics:
Linked List
Please log in to access the Submissions tab, where you can review your progress and explore code submissions from other participants.
Please log in to access the Solution tab and view detailed answers and explanations.
Please log in to access the Discussion tab and join conversations with other participants.
Access Restricted: Please Login to access the code editor and test cases.