Skip to content

Commit 561f239

Browse files
committed
leetcode 328 补充js代码
1 parent 096d624 commit 561f239

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

animation-simulation/链表篇/leetcode328奇偶链表.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,19 @@ public:
8989
};
9090
```
9191

92+
JS Code:
93+
```javascript
94+
var oddEvenList = function(head) {
95+
if(!head || !head.next) return head;
96+
let odd = head, even = head.next, evenHead = even;
97+
while(odd.next && even.next){
98+
odd.next = even.next;
99+
odd = odd.next;
100+
even.next = odd.next;
101+
even = even.next;
102+
}
103+
odd.next = evenHead;
104+
return head;
105+
};
106+
```
107+

0 commit comments

Comments
 (0)