Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

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;
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: unity deactivate all colliders of a gameobject 
Csharp :: void to action c# 
Csharp :: c# get class name by type 
Csharp :: enable fullscreen unity code 
Csharp :: c# remove from list in foreach 
Csharp :: discord bot status code c# 
Csharp :: how to make an object invisible unity 
Csharp :: unity how get random color to material 
Csharp :: call function from another script unity 
Csharp :: loop over enum values 
Csharp :: c# compile into an exe 
Csharp :: how to pass class type to method c# 
Csharp :: trigger collider unity 
Csharp :: dropdown wpf 
Csharp :: c# split on multiple characters 
Csharp :: unity get all components in gameobject 
Csharp :: C# removing the last value of an array 
Csharp :: how to make font c# 
Csharp :: how to split concat string c# 
Csharp :: mute sound unity 
Csharp :: keybyvalue c# 
Csharp :: how to clone something unity 
Csharp :: c# unity detect any keyboard input but not mouse input 
Csharp :: unity get all children 
Csharp :: c# restclient timeout 
Csharp :: how to do a messagebox in c# 
Csharp :: rotate player unity 
Csharp :: c# new dictionary linq 
Csharp :: console.writeline in c# 
Csharp :: asp.net core get root url in view 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =