-
876. Middle of the Linked List javaLeetCode_Study_Plan/LeetCode 75 2022. 10. 5. 23:29
https://leetcode.com/problems/middle-of-the-linked-list/?envType=study-plan&id=level-1
class Solution { public ListNode middleNode(ListNode head) { Map<Integer, ListNode> map = new HashMap(); int i = 0; for (; head != null; i++) { map.put(i, head); head = head.next; } int middle = Math.round(i/2); return map.get(middle); } }
'LeetCode_Study_Plan > LeetCode 75' 카테고리의 다른 글
21. Merge Two Sorted Lists java (0) 2022.10.05 206. Reverse Linked List java (0) 2022.10.05 392. Is Subsequence java (0) 2022.10.04 [LeetCode 75] 중간 점검 (0) 2022.10.02 205. Isomorphic Strings java (0) 2022.09.26