Search
🥉

Middle of the Linked List

Created
2021/12/28 03:46
문제 번호
876
카테고리
Linked List
Two Pointers

Code

제출 날짜
시간
메모리
2021/12/28
0 ms
2 MB
// 876. Middle of the Linked List // // https://leetcode.com/problems/middle-of-the-linked-list/ // Definition for singly-linked list. // type ListNode struct { // Val int // Next *ListNode // } // middleNode function finds the Middle Node from the given linked list. // The specified fast node is incremented by 2. // When the fast node cannot be incremented, then head node is the answer. func middleNode(head *ListNode) *ListNode { for fast := head; fast != nil && fast.Next != nil; fast = fast.Next.Next { head = head.Next } return head }
Go
복사