04 2021 档案

摘要:输入: nums='100,300,50,30,500,103,605,720' k=3 输出:[ 300, 300, 500, 500, 605, 720 ] 大概就是 [100,300,50]找最大值是300;[300,50,30]最大值300,[50,30,500]最大值是500.。。。。 让 阅读全文
posted @ 2021-04-10 09:36 JMH0113 阅读(297) 评论(0) 推荐(0)
摘要:给定不同面额的硬币 coins 和一个总金额 amount。编写一个函数来计算可以凑成总金额所需的最少的硬币个数。如果没有任何一种硬币组合能组成总金额,返回 -1。 你可以认为每种硬币的数量是无限的。 输入:coins = [1, 2, 5], amount = 11 输出:3 解释:11 = 5 阅读全文
posted @ 2021-04-06 10:53 JMH0113 阅读(71) 评论(0) 推荐(0)
摘要:双指针法 var merge = function(nums1, m, nums2, n) { let arr = new Array(m+n).fill(0); let p1 = 0;let p2 = 0; let cur; while(p1<m || p2 < n) { if(p1 m) cur 阅读全文
posted @ 2021-04-05 10:38 JMH0113 阅读(42) 评论(0) 推荐(0)
摘要:class MyPromise { constructor(executor) { this.state = 'pending'; this.value = null; try { executor(this.resolve.bind(this),this.reject.bind(this)); } 阅读全文
posted @ 2021-04-04 10:14 JMH0113 阅读(137) 评论(0) 推荐(0)
摘要:class MyPromise { constructor(executor) { this.state = 'pending'; //初始状态为pending this.value = null; try { // class中默认是严格模式,这个executor是MyPromise中的函数,他的 阅读全文
posted @ 2021-04-03 19:50 JMH0113 阅读(62) 评论(0) 推荐(0)