上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 22 下一页
摘要: 题目链接:https://leetcode-cn.com/problems/check-if-all-the-integers-in-a-range-are-covered/ 题目描述: 给你一个二维整数数组 ranges 和两个整数 left 和 right 。每个 ranges[i] = [st 阅读全文
posted @ 2021-07-23 21:19 张宵 阅读(74) 评论(0) 推荐(0)
摘要: 题目链接:https://leetcode-cn.com/problems/liang-ge-lian-biao-de-di-yi-ge-gong-gong-jie-dian-lcof/ 题目描述: 输入两个链表,找出它们的第一个公共节点。 如下面的两个链表: 在节点 c1 开始相交。 示例 1: 阅读全文
posted @ 2021-07-22 21:41 张宵 阅读(42) 评论(0) 推荐(0)
摘要: 题目链接: https://leetcode-cn.com/problems/3sum-closest/ 题目描述: 题解: class Solution { public: int threeSumClosest(vector<int>& nums, int target) { sort(nums 阅读全文
posted @ 2021-07-21 20:17 张宵 阅读(35) 评论(0) 推荐(0)
摘要: 题目链接:https://leetcode-cn.com/problems/frequency-of-the-most-frequent-element/ 题目描述: 给你一个整数数组 nums 和一个整数 k 。在一步操作中,你可以选择 nums 的一个下标,并将该下标对应元素的值增加 1 。 执 阅读全文
posted @ 2021-07-19 12:28 张宵 阅读(47) 评论(0) 推荐(0)
摘要: 题目链接:https://leetcode-cn.com/problems/remove-duplicate-letters/ 题目描述: 题解: 1.遍历字符串,记录字符出现次数。 2.定义标记数组,记录字符是否重复出现过。 3.为了确保返回结果的字典序最小,使用单调栈。 class Soluti 阅读全文
posted @ 2021-07-17 21:30 张宵 阅读(84) 评论(0) 推荐(0)
摘要: 题目链接:https://leetcode-cn.com/problems/container-with-most-water 题目描述: 给你 n 个非负整数 a1,a2,...,an,每个数代表坐标中的一个点 (i, ai) 。在坐标内画 n 条垂直线,垂直线 i 的两个端点分别为 (i, ai 阅读全文
posted @ 2021-07-16 14:50 张宵 阅读(34) 评论(0) 推荐(0)
摘要: 题目链接:https://leetcode-cn.com/problems/remove-nth-node-from-end-of-list/ 题目描述: 题解: 方法1:先遍历链表长度,再查找倒数第n个节点位置。时间复杂度O(L) /** * Definition for singly-linke 阅读全文
posted @ 2021-07-15 18:05 张宵 阅读(50) 评论(0) 推荐(0)
摘要: 题目链接:https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/ 题目描述: 相关题:买卖股票的最佳时机|| 题解: 参考链接:买卖股票的最佳时机含手续费题解 class Solut 阅读全文
posted @ 2021-07-14 11:56 张宵 阅读(45) 评论(0) 推荐(0)
摘要: 题目链接:https://leetcode-cn.com/problems/monotone-increasing-digits/ 题目描述: 题解: 从后往前遍历,遇到strNum[i - 1] > strNum[i]的情况,让strNum[i - 1]--,然后strNum[i]给为9,可以保证 阅读全文
posted @ 2021-07-13 20:38 张宵 阅读(44) 评论(0) 推荐(0)
摘要: 题目链接: https://leetcode-cn.com/problems/merge-k-sorted-lists/ 题目描述: 给你一个链表数组,每个链表都已经按升序排列。 请你将所有链表合并到一个升序链表中,返回合并后的链表。 题解: 归并法,分而治之的思想。 /** * Definitio 阅读全文
posted @ 2021-07-07 11:23 张宵 阅读(23) 评论(0) 推荐(0)
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 22 下一页