## McAfee Interview Question for Software Engineer / Developers

Comment hidden because of low score. Click to expand.
0
of 0 vote

Actually all of the shapes are variants of Y.
Y: L1[i] = L2[j], i != length(L1), j != length(L2).
L: L1[length(L1)] = L2[length(L2)].
I: L1[0] = L2[0].

Finding the intersection point in straightforward. You know that the lists have a common suffix of size K. Therefore L1 will have P1 = length(L1) - K elements that don't occur in L2, and L2 will have P2 = length(L2) - K elements that don't occur in L1. Based on whether P1 > P2 or P2 > P1, you have to move a pointer in the longest one so that the sublist generated by this pointer has the same length as the shorter one. Now you can simply move this pointer and the head of the shorter list in sync, until they are equal.

As for breaking them up, you have to duplicate the common element and append to a list of your choice.

Cheers

Comment hidden because of low score. Click to expand.
0

Use recursive method, pass head of 2 list node, if LIST meet NULL first then make them to point current LIST2 node and do the same if LIST2 meet NULL first.. And while coming back if both the nodes have diff pointer address then the next of current node will the intersection point.

Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

### Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

### Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.