上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 36 下一页
摘要: type和interface的相同点: 都是用来定义对象或函数的形状;它俩都支持继承,并且可以相互继承。具体形式稍有差别。interface是通过extends实现的,type是通过&实现的。 type和interface的不同点: typeof type可以定义基本类型的别名;type TMySt 阅读全文
posted @ 2023-02-02 11:59 671_MrSix 阅读(114) 评论(0) 推荐(0) 编辑
摘要: /** * 最深层级数组 */ const maxDeepArray = (arr = [1,[2,4],[4], [43,2,[444,1,[54]]], [22,3,[4]], 32]) => { const length = arr.length const fillArray = new A 阅读全文
posted @ 2023-02-02 11:32 671_MrSix 阅读(10) 评论(0) 推荐(0) 编辑
摘要: 给你一个整数数组 nums ,请你找出一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和。 子数组 是数组中的一个连续部分。 const maxSubArray = (nums = [-2,1,-3,4,-1,2,1,-5,4]) => { const length = nums.l 阅读全文
posted @ 2023-02-01 22:49 671_MrSix 阅读(9) 评论(0) 推荐(0) 编辑
摘要: /** * Definition for singly-linked list. * function ListNode(val, next) { * this.val = (val undefined ? 0 : val) * this.next = (next undefined ? null 阅读全文
posted @ 2023-02-01 17:38 671_MrSix 阅读(11) 评论(0) 推荐(0) 编辑
摘要: 给你一个整数数组 nums ,你需要找出一个 连续子数组 ,如果对这个子数组进行升序排序,那么整个数组都会变为升序排序。 请你找出符合题意的 最短 子数组,并输出它的长度。 const findUnsortedSubarray = (nums) => { const length = nums.le 阅读全文
posted @ 2023-02-01 14:43 671_MrSix 阅读(10) 评论(0) 推荐(0) 编辑
摘要: const countSubstrings = (s) => { let len = s.length if([0,1].includes(len)) return len let res = 0 const getStr = (s, l, r) => { while(l >= 0 && r <= 阅读全文
posted @ 2023-02-01 14:06 671_MrSix 阅读(9) 评论(0) 推荐(0) 编辑
摘要: 给定一个未排序的整数数组 nums ,找出数字连续的最长序列(不要求序列元素在原数组中连续)的长度。 请你设计并实现时间复杂度为 O(n) 的算法解决此问题。 /** * @param {number[]} nums * @return {number} */ const longestConsec 阅读全文
posted @ 2023-02-01 13:19 671_MrSix 阅读(8) 评论(0) 推荐(0) 编辑
摘要: /** * Definition for singly-linked list. * function ListNode(val, next) { * this.val = (val undefined ? 0 : val) * this.next = (next undefined ? null 阅读全文
posted @ 2023-02-01 00:30 671_MrSix 阅读(8) 评论(0) 推荐(0) 编辑
摘要: /** * Definition for singly-linked list. * function ListNode(val, next) { * this.val = (val undefined ? 0 : val) * this.next = (next undefined ? null 阅读全文
posted @ 2023-01-31 23:26 671_MrSix 阅读(7) 评论(0) 推荐(0) 编辑
摘要: 编写一个函数,其作用是将输入的字符串反转过来。输入字符串以字符数组 s 的形式给出。 不要给另外的数组分配额外的空间,你必须原地修改输入数组、使用 O(1) 的额外空间解决这一问题。 /** * @param {character[]} s * @return {void} Do not retur 阅读全文
posted @ 2023-01-30 21:35 671_MrSix 阅读(14) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 36 下一页