Kotlin
\n/**\n * Example:\n * var li = ListNode(5)\n * var v = li.`val`\n * Definition for singly-linked list.\n * class ListNode(var `val`: Int) {\n *     var next: L
```\n/**\n * Example:\n * var li = ListNode(5)\n * var v = li.`val`\n * Definition for singly-linked list.\n * class ListNode(var `val`: Int) {\n *     var next: ListNode? = null\n * }\n */\nclass Solution {\n    fun middleNode(head: ListNode?): ListNode? {\n        var fast: ListNode? = head\n        var slow: ListNode? = head\n        \n        while (fast != null && fast?.next != null) {\n            fast = fast?.next?.next\n            slow = slow?.next\n        }\n        \n        return slow\n    }\n}\n```
['Kotlin']