leetcode,JavaScript利用数组生成链表
生成链表
function ListNode(val, next) {
this.val = (val === undefined ? 0 : val)
this.next = (next === undefined ? null : next)
}
let getList = function makeList(array) {
let head = new ListNode()
let cur = head
for(let i = 0; i < array.length; i+
原创
2021-07-16 14:01:00 ·
307 阅读 ·
0 评论