找最小值的算法
去重的算法
<script>
var arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 5, 5, 6, 7, 8, 9, 0, 0, 3, 4, 5]; function findInArr(arr,n){ for(var i = 0; i < arr.length; i++){ if(arr[i] == n)return true; } return false; } function removeDup(arr, s, e){ if(s > e){ return false; }else if(s == e){ return [arr[s]]; } var c = Math.floor((s + e) / 2); var l = removeDup(arr, s, c); var r = removeDup(arr, c + 1, e); for(var i = 0; i < r.length; i++){ if(!findInArr(l,r[i])){ l.push(r[i]); } } return l; } console.log(removeDup(arr, 0, arr.length - 1)); </script>