摘要: LeetCode242有效的字母异位词 tag: #哈希表 #数组 leetcode 地址:242. 有效的字母异位词 代码: // 通过数组的方式对每个字母进行统计数量,然后遍历数组,查看是否每一项都为0 function isAnagram(s: string, t: string): bool 阅读全文
posted @ 2022-12-12 23:07 牡蛎枯枯 阅读(16) 评论(0) 推荐(0)
摘要: 24. 两两交换链表中的节点 tag: #链表 #反转 leetcode 地址:24. 两两交换链表中的节点 代码: function swapPairs(head: ListNode | null): ListNode | null { const resHead = new ListNode() 阅读全文
posted @ 2022-12-11 21:22 牡蛎枯枯 阅读(16) 评论(0) 推荐(0)
摘要: 203. 移除链表元素 tag: #链表 leetcode 地址:203. 移除链表元素 代码: function removeElements(head: ListNode | null, val: number): ListNode | null { const newHead = new Li 阅读全文
posted @ 2022-12-09 21:05 牡蛎枯枯 阅读(14) 评论(0) 推荐(0)
摘要: 977.有序数组的平方 tag: #双指针 leetcode 地址:977. 有序数组的平方 代码: function sortedSquares(nums: number[]): number[] { const res = [] let left = 0, right = nums.length 阅读全文
posted @ 2022-12-08 22:10 牡蛎枯枯 阅读(20) 评论(0) 推荐(0)
摘要: tag: #二分 #循环不变量 leetcode 地址:704. 二分查找 代码: function search(nums: number[], target: number): number { let left = 0, right = nums.length - 1 // 我们假设 targ 阅读全文
posted @ 2022-12-08 10:05 牡蛎枯枯 阅读(27) 评论(0) 推荐(0)
点击右上角即可分享
微信分享提示