链表中位数(Middle of the Linked List)
生活随笔
收集整理的這篇文章主要介紹了
链表中位数(Middle of the Linked List)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
一、學習要點
1.鏈表知識的回顧;
2.鏈表結點數組;
二、代碼
class Solution {
public ListNode middleNode(ListNode head) {
ListNode[] array = new ListNode[100];
int count = 0;
while (head != null) {
array[count++] = head;
head = head.next;
}
return array[count / 2];
}
};
總結
以上是生活随笔為你收集整理的链表中位数(Middle of the Linked List)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 图像倒转90度(Rotate Image
- 下一篇: 链表中是否存在环的问题,及环入口在链表中