Yosgi
Yosgi
Avatar
😀
2 results for Linked List
  • 考虑到头部也可能产生反转,所以需要一个虚拟头。 在遍历的过程中记录反转后的尾节点和之前的节点。 最后进行节点的链接处理。 var reverseBetween = function(head, m, n) { let noob = new ListNode(0) noob.next = head let cur = noob let index = 0 let A,B while (index < …
    Algorithms Created Fri, 23 Jul 2021 00:00:00 +1200
  • 拿到题目的想法是使用双指针指向新旧节点,再加上一个 map 用来映射旧节点和新节点。 递归 var listMap = new Map() var copyRandomList = function(head) { if(head === null) return head if (listMap.get(head)) { return listMap.get(head) } let …
    Algorithms Created Thu, 22 Jul 2021 00:00:00 +1200