Skip to content

Commit 8dc73fe

Browse files
authored
Update 2130-maximum-twin-sum-of-a-linked-list.js
Moving the main function on top.
1 parent a11ed6f commit 8dc73fe

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

Diff for: javascript/2130-maximum-twin-sum-of-a-linked-list.js

+23-22
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,6 @@
1212
* @param {ListNode} head
1313
* @return {number}
1414
*/
15-
const llLength = (head) => {
16-
let count = 0;
17-
while (head) {
18-
head = head.next;
19-
count++;
20-
}
21-
return count;
22-
};
23-
24-
const reverseLL = (head, len) => {
25-
let count = 0;
26-
let temp = null;
27-
while (count < len) {
28-
const next = head.next;
29-
head.next = temp;
30-
temp = head;
31-
head = next;
32-
count++;
33-
}
34-
return temp;
35-
};
36-
3715
var pairSum = function (head) {
3816
const mid = llLength(head) / 2;
3917

@@ -57,3 +35,26 @@ var pairSum = function (head) {
5735

5836
return max;
5937
};
38+
39+
40+
var llLength = (head) => {
41+
let count = 0;
42+
while (head) {
43+
head = head.next;
44+
count++;
45+
}
46+
return count;
47+
};
48+
49+
var reverseLL = (head, len) => {
50+
let count = 0;
51+
let temp = null;
52+
while (count < len) {
53+
const next = head.next;
54+
head.next = temp;
55+
temp = head;
56+
head = next;
57+
count++;
58+
}
59+
return temp;
60+
};

0 commit comments

Comments
 (0)