var countArr = [1,2,3,4,5,6,3,4,3,3,7,8,9,32,1,11,2,3,3,3]; var res = {}; var maxnum=0; var max; function getRepeat(arr){ for (var i = 0; i < arr.length; i++) { if(!res[arr[i]]){ res[arr[i]] = 1; }else{ res[arr[i]] ++; } }; var keys = Object.keys(res
找出数字数组中最大的数 var Match = (function(){ var arr = null; var len = 0; return { max:function(arr,len){ arr = arr; len = arr.length; var newArr = arr.sort(); return newArr[len-1]; } } })(); var maxCount = Match.max([3,4,5,11,3,4,55,67,88,33]); console.log(
Level: Easy 题目描述: Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements of [1, n] inclusive that do not appear in this array. Could you do it without extra space
Given an array of integers and an integer k, you need to find the number of unique k-diff pairs in the array. Here a k-diff pair is defined as an integer pair (i, j), where i and j are both numbers in the array and their absolute difference is k. Exa