Horje
Check if two linked lists merge. If so, where? Code Example
Check if two linked lists merge. If so, where?
int FindMergeNode(Node headA, Node headB) {
  Node currentA = headA;
  Node currentB = headB;

  // Do till the two nodes are the same
  while (currentA != currentB) {
    // If you reached the end of one list start at the beginning of the other
    // one currentA
    if (currentA.next == null) {
      currentA = headA;
    } else {
      currentA = currentA.next;
    }
    // currentB
    if (currentB.next == null) {
      currentB = headB;
    } else {
      currentB = currentB.next;
    }
  }
  return currentB.data;
}




Csharp

Related
c# loop array backwards Code Example c# loop array backwards Code Example
iterate through xpdictionary devexpress Code Example iterate through xpdictionary devexpress Code Example
merge point Code Example merge point Code Example
is c# hard to learn Code Example is c# hard to learn Code Example
access to element in object c# Code Example access to element in object c# Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10