leetcode 328 补充js代码

pull/22/head
daluozha 2021-05-05 04:13:37 +08:00
parent 096d624df3
commit 561f2390c0
1 changed files with 16 additions and 0 deletions

View File

@ -89,3 +89,19 @@ public:
};
```
JS Code:
```javascript
var oddEvenList = function(head) {
if(!head || !head.next) return head;
let odd = head, even = head.next, evenHead = even;
while(odd.next && even.next){
odd.next = even.next;
odd = odd.next;
even.next = odd.next;
even = even.next;
}
odd.next = evenHead;
return head;
};
```