此为历史版本和 IPFS 入口查阅区,回到作品页
Zoka
IPFS 指纹 这是什么

作品指纹

LeetCode 876. Middle of the Linked List (Java)

Zoka
·
·
/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode() {}
 *     ListNode(int val) { this.val = val; }
 *     ListNode(int val, ListNode next) { this.val = val; this.next = next; }
 * }
 */
class Solution {
    public ListNode middleNode(ListNode head) {
        ListNode[] A = new ListNode[100];
        int i = 0;
        while (head != null) {
            A[i] = head;
            head = head.next;
            i++;
        }
        return A[i/2];
    }
}


CC BY-NC-ND 2.0 授权