Day4
This commit is contained in:
15
876. Middle of the Linked List/Solution.cs
Normal file
15
876. Middle of the Linked List/Solution.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace _876._Middle_of_the_Linked_List;
|
||||
|
||||
public class Solution
|
||||
{
|
||||
public ListNode MiddleNode(ListNode? head)
|
||||
{
|
||||
ListNode result = head!;
|
||||
while(head?.next != null)
|
||||
{
|
||||
head = head?.next?.next;
|
||||
result = result!.next!;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user