算法
对酒丶当歌
在成功的路上,不可或缺的是身边的人
展开
-
基础算法: 字符串:截取浏览器href后的字段查询
我们可以通过location可以访问到绝大多数对象的信息,但其中访问URL包含的查询字符创的属性并不是很方便.尽管location.search能返回问好到URL末尾的所有内容.但还是没办法访问其中的每个查询字符串参数. 因为我们可以自己创建一个函数,解析返回字符创 function SearchQuert() { var qs =window.locat...原创 2018-04-30 11:22:39 · 336 阅读 · 1 评论 -
初级算法---数组(一) :数组删除重复项
最近才刚开始写起算法,也不知道自己写的对不对,每天自己小练一次,希望能有个进步给定 nums = [0,0,1,1,1,2,2,3,3,4], 函数应该返回新的长度 5, 并且原数组 nums 的前五个元素被修改为 0, 1, 2, 3, 4。 var sum= Splice([1,1,2,52,3,4,5,6]); console.log(sum); console.log(s...原创 2018-04-26 22:42:34 · 176 阅读 · 0 评论 -
js基础算法--数组:判断去重
function mus(nums){ var nary =nums.sort(); console.log(nary); for(var i=0; i<nums.length; i++){ if (nums[i]==nary[i+1]){ return true } else { ...原创 2018-04-27 23:50:05 · 131 阅读 · 0 评论 -
基础算法:数组 两数之和
给定一个整数数组和一个目标值,找出数组中和为目标值的两个数。你可以假设每个输入只对应一种答案,且同样的元素不能被重复利用。示例:给定 nums = [2, 7, 11, 15], target = 9 因为 nums[0] + nums[1] = 2 + 7 = 9 所以返回 [0, 1] //方法一var target =10; var nums =[2,15,8,1,15]; console...原创 2018-04-28 16:39:11 · 344 阅读 · 0 评论 -
js 常用时间转换
Date.prototype.format = function (format) { var o = { "M+": this.getMonth() + 1, //month "d+": this.getDate(), //day "h+": this.getHours(), //hour "m+": this.getMinutes(), //minute "s+": this.ge...原创 2018-07-28 14:32:31 · 178 阅读 · 0 评论