
数组
码不停Ti
信息安全在校大学生
展开
-
【LeetCode】39. 组合总和
给定一个无重复元素的数组candidates和一个目标数target,找出candidates中所有可以使数字和为target的组合。candidates中的数字可以无限制重复被选取。说明:所有数字(包括target)都是正整数。解集不能包含重复的组合。示例1:输入: candidates = [2,3,6,7], target = 7,所求解集为:...原创 2020-02-03 07:56:36 · 436 阅读 · 0 评论 -
【LeetCode】56. 合并区间
给出一个区间的集合,请合并所有重叠的区间。示例 1:输入: [[1,3],[2,6],[8,10],[15,18]]输出: [[1,6],[8,10],[15,18]]解释: 区间 [1,3] 和 [2,6] 重叠, 将它们合并为 [1,6].示例2:输入: [[1,4],[4,5]]输出: [[1,5]]解释: 区间 [1,4] 和 [4,5] 可被视为重叠区间。来源...原创 2020-01-12 17:56:16 · 391 阅读 · 0 评论 -
【LeetCode】62. 不同路径
一个机器人位于一个 m x n 网格的左上角 (起始点在下图中标记为“Start” )。机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角(在下图中标记为“Finish”)。问总共有多少条不同的路径?例如,上图是一个7 x 3 的网格。有多少可能的路径?说明:m和 n 的值均不超过 100。示例1:输入: m = 3, n = 2输出: 3解释:从...原创 2020-01-11 12:56:59 · 338 阅读 · 0 评论 -
【LeetCode】55. 跳跃游戏
给定一个非负整数数组,你最初位于数组的第一个位置。数组中的每个元素代表你在该位置可以跳跃的最大长度。判断你是否能够到达最后一个位置。示例1:输入: [2,3,1,1,4]输出: true解释: 我们可以先跳 1 步,从位置 0 到达 位置 1, 然后再从位置 1 跳 3 步到达最后一个位置。示例2:输入: [3,2,1,0,4]输出: false解释: 无论怎样,...原创 2020-01-11 12:42:25 · 443 阅读 · 0 评论 -
【LeetCode】42. 接雨水
给定n 个非负整数表示每个宽度为 1 的柱子的高度图,计算按此排列的柱子,下雨之后能接多少雨水。上面是由数组 [0,1,0,2,1,0,1,3,2,1,2,1] 表示的高度图,在这种情况下,可以接 6 个单位的雨水(蓝色部分表示雨水)。感谢 Marcos 贡献此图。示例:输入: [0,1,0,2,1,0,1,3,2,1,2,1]输出: 6在真实的面试中遇到过这道题?来源...原创 2020-01-11 12:26:46 · 381 阅读 · 0 评论 -
【LeetCode】两个数组的交集 II
给定两个数组,编写一个函数来计算它们的交集。示例 1:输入: nums1 = [1,2,2,1], nums2 = [2,2]输出: [2,2]示例 2:输入: nums1 = [4,9,5], nums2 = [9,4,9,8,4]输出: [4,9]说明:输出结果中每个元素出现的次数,应与元素在两个数组中出现的次数一致。 我们可以不考虑输出结果的顺序。进阶:...原创 2020-01-08 10:58:32 · 278 阅读 · 0 评论 -
【LeetCode】48. 旋转图像
参考https://blog.youkuaiyun.com/wuzhongqiang/article/details/103221743给定一个 n×n 的二维矩阵表示一个图像。将图像顺时针旋转 90 度。说明:你必须在原地旋转图像,这意味着你需要直接修改输入的二维矩阵。请不要使用另一个矩阵来旋转图像。示例 1:给定 matrix =[ [1,2,3], [4,5,6...原创 2019-12-09 19:30:46 · 414 阅读 · 0 评论 -
【LeetCode】581. Shortest Unsorted Continuous Subarray
Given an integer array, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array will be sorted in ascending order, too.You need to find ...原创 2019-10-08 11:28:47 · 372 阅读 · 0 评论 -
【LeetCode】448. Find All Numbers Disappeared in an Array
Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements of [1, n] inclusive that do not appear in this array.Coul...原创 2019-10-08 10:44:04 · 390 阅读 · 0 评论 -
【LeetCode】15. 3Sum
Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note:The solution set must not cont...原创 2019-10-07 17:29:42 · 335 阅读 · 0 评论 -
【Leet Code】283. Move Zeroes
Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.Example:Input: [0,1,0,3,12]Output: [1,3,12,0,0]Note:You mus...原创 2019-10-04 20:16:05 · 349 阅读 · 0 评论 -
【LeetCode】 11. Container With Most Water
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two...原创 2019-10-03 00:57:07 · 307 阅读 · 0 评论 -
【Leet Code】26. Remove Duplicates from Sorted Array
Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this by modifyi...原创 2019-09-27 13:45:38 · 394 阅读 · 0 评论 -
【Leet Code】1. Two Sum
1. Two SumGiven an array of integers, returnindicesof the two numbers such that they add up to a specific target.You may assume that each input would haveexactlyone solution, and you may not u...原创 2019-09-25 21:52:16 · 415 阅读 · 0 评论