摘要: 原型链实现继承 基本模式 function SuperType(){ this.property = true; } SuperType.prototype.getSuperValue = function(){ console.log(this); return this.property; } 阅读全文
posted @ 2020-07-15 05:37 studystudyxinxin 阅读(201) 评论(0) 推荐(0) 编辑
摘要: 力扣链接:https://leetcode-cn.com/problems/he-wei-sde-lian-xu-zheng-shu-xu-lie-lcof/ 题目描述 输入一个正整数 target ,输出所有和为 target 的连续正整数序列(至少含有两个数)。 序列内的数字由小到大排列,不同序 阅读全文
posted @ 2020-07-13 23:02 studystudyxinxin 阅读(97) 评论(0) 推荐(0) 编辑
摘要: 力扣链接:https://leetcode-cn.com/problems/he-wei-sde-liang-ge-shu-zi-lcof/ 题目描述 输入一个递增排序的数组和一个数字s,在数组中查找两个数,使得它们的和正好是s。如果有多对数字的和等于s,则输出任意一对即可。 思路1: 哈希表 先建 阅读全文
posted @ 2020-07-13 22:06 studystudyxinxin 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 力扣链接:https://leetcode-cn.com/problems/1nzheng-shu-zhong-1chu-xian-de-ci-shu-lcof/ 题目描述 输入一个整数 n ,求1~n这n个整数的十进制表示中1出现的次数。 例如,输入12,1~12这些整数中包含1 的数字有1、10 阅读全文
posted @ 2020-07-10 00:39 studystudyxinxin 阅读(113) 评论(0) 推荐(0) 编辑
摘要: 力扣链接:https://leetcode-cn.com/problems/shu-zu-zhong-shu-zi-chu-xian-de-ci-shu-ii-lcof/ 题目描述 在一个数组 nums 中除一个数字只出现一次之外,其他数字都出现了三次。请找出那个只出现一次的数字。 1 <= num 阅读全文
posted @ 2020-07-08 08:14 studystudyxinxin 阅读(89) 评论(0) 推荐(0) 编辑
摘要: 题目描述 一个整型数组 nums 里除两个数字之外,其他数字都出现了两次。请写程序找出这两个只出现一次的数字。要求时间复杂度是O(n),空间复杂度是O(1)。 思路:位运算 异或运算复习 功能:相同为0,不同为1 运用:与0异或不变,与1异或取反 根据异或的性质很容易得出,假设数组中只有一个数字只出 阅读全文
posted @ 2020-07-08 05:36 studystudyxinxin 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 工厂模式 用一个“生产”对象的函数(工厂),该函数接收属性的值作为参数,生成一个对象(产品)并返回。 function createPerson(name, age, job){ let o = new Object(); o.name = name; o.age = age; o.job = jo 阅读全文
posted @ 2020-07-04 09:19 studystudyxinxin 阅读(273) 评论(0) 推荐(0) 编辑
摘要: 力扣链接:https://leetcode-cn.com/problems/er-cha-sou-suo-shu-de-di-kda-jie-dian-lcof/ 题目描述 给定一棵二叉搜索树,请找出其中第k大的节点。 思路:中序遍历变体 按右->root->左的顺序遍历,并计数K 代码: /** 阅读全文
posted @ 2020-07-03 22:28 studystudyxinxin 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 力扣链接:https://leetcode-cn.com/problems/que-shi-de-shu-zi-lcof 题目描述 一个长度为n-1的递增排序数组中的所有数字都是唯一的,并且每个数字都在范围0~n-1之内。在范围0~n-1内的n个数字中有且只有一个数字不在该数组中,请找出这个数字。 阅读全文
posted @ 2020-07-03 21:06 studystudyxinxin 阅读(111) 评论(0) 推荐(0) 编辑
摘要: Data Property 1. Attributes 数据属性指对象中那些有自己的值的属性(与下文Accessor Property相对),共有四个Attributes : [[Configurable]] - “可配置的”,默认为True 标识该属性(Property)是否可以被delete删除 阅读全文
posted @ 2020-07-03 12:33 studystudyxinxin 阅读(653) 评论(0) 推荐(0) 编辑