Skip to content

Latest commit

 

History

History
29 lines (21 loc) · 618 Bytes

leetcode_876.md

File metadata and controls

29 lines (21 loc) · 618 Bytes

LeetCode Problems

876. Middle of the Linked List

class Solution {
    fun middleNode(head: ListNode?): ListNode? {
        var front = head
        var back = head
        // move 2step on front node
        // move 1step on back node, it will stop at middle node. ( 2 : 1 )
        while (front?.next != null) {
            front = front?.next?.next
            back = back?.next
        }
        return back
    }
}