标签:style class blog c code java
var arr = [1,2,2,3,3,4,4,5,1]; function getRepeat( arr ){ var len = arr.length, map={}; for( var i = 0;i<len;i++ ){ if(!map[arr[i]]){ map[arr[i]] = 1; }else{ map[arr[i]] = map[arr[i]]+1; } } for( var n in map ){ if( map[n] == 1){ return n; } } } console.log( getRepeat(arr) );
查看数组中重复次数最少的。
标签:style class blog c code java
原文地址:http://www.cnblogs.com/lovezheng/p/3737462.html