Intersection of Linked List
Given 2 linked lists which merge at some point. Find the node at which the lists merge.
CodingNinjas
author
2y
Parallel Traversal Approach
- Calculate the length of both the lists, say len1 and len2
- Get the absolute difference of the lengths, diff = |len1 – len2|
- Now traverse the long list from the first node till ...read more
CodingNinjas
author
2y
- First I suggested the brute force approach in which we check each element of the first linked list with each element of other linked list and then moved on to the better-optimized solution using linke...read more
CodingNinjas
author
2y
Brute Force
- For each node in the first list, traverse the entire second list
- Check if any node in the second list coincides with the first list
- If it does, return that node’s data
- If it doesn’t, return -1...read more
CodingNinjas
author
2y
Hashing Approach
- Traverse the first list and store the address/reference to each node in a hash set/map/dictionary.
- Then check every node in the second list:
- If the address of the node of the second list...read more
Add answer anonymously...
Top American Express Software Developer interview questions & answers
Popular interview questions of Software Developer
Top HR questions asked in American Express Software Developer
>
American Express Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app