1.代码如下: var toObject = function(a) { var o = {}; for (var i=0, j=a.length; i<j; i=i+1) { // 这里我调整了下, YUI源码中是i<a.length o[a[i]] = true; } return o; } var keys = function(o) { var a=[], i; for (i in o) { if (o.hasOwnProperty(i)) { // 这里, YUI源码中是lang.h…
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. For example,Given 1->2->3->3->4->4->5, return 1->2->5.Given 1->1->1->2->3, return 2->3.…
2.1 Write code to remove duplicates from an unsorted linked list.FOLLOW UPHow would you solve this problem if a temporary buffer is not allowed? 这道题让我们移除无序链表中的重复项,在LeetCode中有两道类似的题是Remove Duplicates from Sorted List 移除有序链表中的重复项 和 Remove Duplicates fr…