主题索引
文章平均质量分 86
Jay_1998
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
LeetCode 1186. 删除一次得到子数组最大和
LeetCode 1186. 删除一次得到子数组最大和给你一个整数数组,返回它的某个 非空 子数组(连续元素)在执行一次可选的删除操作后,所能得到的最大元素总和。换句话说,你可以从原数组中选出一个子数组,并可以决定要不要从中删除一个元素(只能删一次哦),(删除后)子数组中至少应当有一个元素,然后该子数组(剩下)的元素总和是所有子数组之中最大的。注意,删除一个元素后,子数组 不能为空。Example1输入:arr = [1,-2,0,3]输出:4解释:我们可以选出 [1, -2, 0, 3],然原创 2020-11-21 09:52:43 · 519 阅读 · 0 评论 -
LeetCode 42 Trapping Rain Water 收集雨水
LeetCode 42 Trapping Rain Water 收集雨水Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.Example1Input: [0,1,0,2,1,0,1,3,2,1,2,1]Output: 6解题思路可以使用单调栈来做,原创 2020-11-17 16:12:24 · 209 阅读 · 0 评论 -
LeetCode 403 Frog Jump 青蛙过河
LeetCode 403 Frog Jump 青蛙过河A frog is crossing a river. The river is divided into x units and at each unit there may or may not exist a stone. The frog can jump on a stone, but it must not jump into the water.Given a list of stones’ positions (in units) i原创 2020-11-17 14:37:28 · 336 阅读 · 0 评论 -
[LeetCode] 57. Insert Interval 插入区间
[LeetCode] 57. Insert Interval 插入区间给出一个无重叠的 ,按照区间起始端点排序的区间列表。在列表中插入一个新的区间,你需要确保列表中的区间仍然有序且不重叠(如果有必要的话,可以合并区间)Example1:输入:intervals = [[1,3],[6,9]], newInterval = [2,5]输出:[[1,5],[6,9]]Example2:输入:intervals = [[1,2],[3,5],[6,7],[8,10],[12,16]], newIn原创 2020-09-28 23:50:56 · 248 阅读 · 0 评论 -
[LeetCode] 56. Merge Intervals 合并区间
[LeetCode] 56. Merge Intervals 合并区间给出一个区间的集合,请合并所有重叠的区间。Example 1:输入: intervals = [[1,3],[2,6],[8,10],[15,18]]输出: [[1,6],[8,10],[15,18]]解释: 区间 [1,3] 和 [2,6] 重叠, 将它们合并为 [1,6].Example 2:输入: intervals = [[1,4],[4,5]]输出: [[1,5]]解释: 区间 [1,4] 和 [4,5] 可原创 2020-09-27 10:32:54 · 237 阅读 · 0 评论 -
LeetCode 55 Jump Game 跳跃游戏
LeetCode 55 Jump Game 跳跃游戏Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine if you are able to reach the last inde原创 2020-09-24 00:05:07 · 156 阅读 · 0 评论 -
LeetCode 47 Permutations II 全排列之二
LeetCode 47 Permutations II 全排列之二Given a collection of numbers that might contain duplicates, return all possible unique permutations.ExampleInput: [1,1,2]Output:[ [1,1,2], [1,2,1], [2,1,1]]解题思路这题和LeetCode 46 全排列大致相同,由于输入数组有可能出现重复数字,这里我们需要进行剪原创 2020-08-08 20:20:24 · 216 阅读 · 0 评论 -
LeetCode 77 组合项
LeetCode 77 Combinations 组合项Given two integers n and k, return all possible combinations of k numbers out of 1 … n.ExampleIf n = 4 and k = 2, a solution is:[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4],]解题思路让求1到n共n个数字里k个数的组合数的所有情况,用深度优先搜索DFS原创 2020-08-08 20:03:41 · 299 阅读 · 0 评论 -
LeetCode 46 全排列 permutations
LeetCode 46 全排列Given a collection of distinct integers, return all possible permutations.ExampleInput: [1,2,3]Output:[ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1]]解题思路求全排列问题,用递归 DFS 来求解。这里需要用到一个 visited 数组来标记某个数字是否访问过,然后在 DFS 递原创 2020-08-08 20:11:05 · 183 阅读 · 0 评论 -
LeetCode题目索引(题目+解析+AC代码)
IDName3最长无重复字符的子串原创 2020-08-08 19:47:51 · 404 阅读 · 0 评论 -
LeetCode 3最长无重复字符的子串
LeetCode 3最长无重复字符的子串给定一个字符串,请你找出其中不含有重复字符的 最长子串 的长度。input 1:Input: "abcabcbb"Output: 3 Explanation: The answer is "abc", with the length of 3. input 2:Input: "bbbbb"Output: 1Explanation: The answer is "b", with the length of 1.input 3:Input: "pw原创 2020-08-07 16:41:26 · 156 阅读 · 0 评论
分享