ruby solution using 2 pointers with explanation
2 pointers , one \'fast\' & another slow aka \'middle\'. The \'fast\' pointer moves twice as fast as the \'middle\' pointer i.e. it moves forward 2 steps for ev
2 pointers , one \'fast\' & another slow aka \'middle\'. The \'fast\' pointer moves twice as fast as the \'middle\' pointer i.e. it moves forward 2 steps for every 1 step taken by the slow aka \'middle\' pointer \nso when \'fast\' reaches end of the linked list, \'middle\' will have reached the middle of the list. \n\t\n```\n# Definition for singly-linked list.\n# class ListNode\n#     attr_accessor :val, :next\n#     def initialize(val = 0, _next = nil)\n#         @val = val\n#         @next = _next\n#     end\n# end\n# @param {ListNode} head\n# @return {ListNode}\ndef middle_node(head)\n    fast = middle = head\n    while fast && fast.next do\n        middle = middle.next\n        fast = (fast.next).next\n    end\n    return middle\nend\n```
['Ruby']