lianjianbo / blog

0 stars 0 forks source link

ARTS第二十三周(2019.12.09-2019.12.15) #26

Open lianjianbo opened 4 years ago

lianjianbo commented 4 years ago

ARTS第二十三周(2019.12.09-2019.12.15)

Algorithm 删除链表的倒数第N个节点

地址:https://leetcode-cn.com/explore/interview/card/top-interview-questions-easy/6/linked-list/42/ 代码:

var removeNthFromEnd = function(head, n) {
    let last = head;
    for(let i = 0; i < n; i++){
        last = last.next;
    }
    if(!last) return head.next;
    let first = head;
    while(last.next){
        first = first.next;
        last = last.next;
    }
    first.next = first.next.next;
    return head;
};

Review JS 中为啥使用 JSON 来代替简单对象会更快

地址:https://juejin.im/post/5e03fefe518825127d10934d

Tip 近期遇到的tips