Java || Best Solution ✅|| O(n) Time complexity ✅|| Beats 100% ✅
Complexity\n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(1)\n Add your space complexity here, e.g. O(n) \n\n# Co
# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/**\n * Definition for singly-linked list.\n * public class ListNode {\n *     int val;\n *     ListNode next;\n *     ListNode() {}\n *     ListNode(int val) { this.val = val; }\n *     ListNode(int val, ListNode next) { this.val = val; this.next = next; }\n * }\n */\nclass Solution {\n    public ListNode middleNode(ListNode head) {\n        ListNode node_count = head;\n        int count = 0;\n        while (node_count != null) {\n            node_count = node_count.next;\n            count++;\n        }\n        ListNode current = head;\n        for (int i = 0; i < count / 2; i++) {\n            current = current.next;\n        }\n        return current;\n    }\n}\n```\n![please-upvote-and.jpg](https://assets.leetcode.com/users/images/8873f9b1-dfa4-4d9c-bb67-1b6db9d65e35_1674992431.3815322.jpeg)
['Java']