We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 152cbea + f6e9d17 commit aa783dfCopy full SHA for aa783df
javascript/876-Middle-Of-The-Linked-List.js
@@ -0,0 +1,21 @@
1
+/**
2
+ * https://leetcode.com/problems/middle-of-the-linked-list/
3
+ * Definition for singly-linked list.
4
+ * function ListNode(val, next) {
5
+ * this.val = (val===undefined ? 0 : val)
6
+ * this.next = (next===undefined ? null : next)
7
+ * }
8
+ */
9
10
+ * @param {ListNode} head
11
+ * @return {ListNode}
12
13
+var middleNode = function (head) {
14
+ let first = head;
15
+ let second = head;
16
+ while (second != null && second.next != null) {
17
+ first = first.next;
18
+ second = second.next.next;
19
+ }
20
+ return first;
21
+};
0 commit comments