Intersection of Linked List You are given two Singly Linked List of integers, which are merging at some node of a third linked list. Your task is to find the data of the node at which merging starts. If there is no merging, return -1. For example:- The given Linked Lists, where a1, a2, c1 is the first linked list, b1, ...
read more
CodingNinjas
author
2y
Brute ForceFor each node in the first list, traverse the entire second listCheck if any node in the second list coincides with the first listIf it does, return that node’s dataIf it doesn’t, return -1...
see more
CodingNinjas
author
2y
Hashing ApproachTraverse 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...
see more
CodingNinjas
author
2y
Parallel Traversal ApproachCalculate the length of both the lists, say len1 and len2Get the absolute difference of the lengths, diff = |len1 – len2|Now traverse the long list from the first node till ...
see more
Add answer anonymously...
Top Freshworks Software Engineer interview questions & answers
Popular interview questions of Software Engineer
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