
LEETCODE
Ryiiiin
一个喜欢刘人语的人。
展开
-
[LeetCode] 35. Search Insert Position
题目内容https://leetcode-cn.com/problems/search-insert-position/Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were ...原创 2019-04-10 14:57:40 · 111 阅读 · 0 评论 -
[LeetCode] 39. Combination Sum
题目内容给定一个无重复元素的数组candidates和一个目标数target,找出candidates中所有可以使数字和为target的组合。candidates中的数字可以无限制重复被选取。https://leetcode-cn.com/problems/combination-sum/Given asetof candidate numbers (cand...原创 2019-04-10 21:27:20 · 106 阅读 · 0 评论 -
[LeetCode] 42. Trapping Rain Water
题目内容Givennnon-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.上面是由数组 [0,1,0,2,1,0,1,3,2,1,2,1] 表示的高度图,...原创 2019-04-10 21:52:32 · 86 阅读 · 0 评论 -
[LeetCode] 46. Permutations
题目内容给定一个没有重复数字的序列,返回其所有可能的全排列。https://leetcode-cn.com/problems/permutations/Given a collection ofdistinctintegers, return all possible permutations.Example:Input: [1,2,3]Output:[ [1,2...原创 2019-04-10 22:41:37 · 104 阅读 · 0 评论 -
[LeetCode] 48. Rotate Image
题目内容https://leetcode-cn.com/problems/rotate-image/You are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Note:You have to rotate the imagein-place...原创 2019-04-10 23:27:24 · 96 阅读 · 0 评论 -
[LeetCode] 49. Group Anagrams
题目内容https://leetcode-cn.com/problems/group-anagrams/Given an array of strings, group anagrams together.Note:All inputs will be in lowercase. The order of your output does notmatter.Example...原创 2019-04-11 14:43:03 · 144 阅读 · 0 评论 -
[LeetCode] 5.Longest Palindromic Substring
题目内容给定一个字符串s,找到s中最长的回文子串。你可以假设s的最大长度为 1000。https://leetcode-cn.com/problems/longest-palindromic-substring/Given a strings, find the longest palindromic substring ins. You may assume that ...原创 2019-04-08 14:14:51 · 135 阅读 · 0 评论 -
[LeetCode] 53. Maximum Subarray
题目内容https://leetcode-cn.com/problems/maximum-subarray/Given an integer arraynums, find the contiguous subarray(containing at least one number) which has the largest sum and return its sum.Exa...原创 2019-04-11 19:02:11 · 112 阅读 · 0 评论 -
[LeetCode] 55. Jump Game
题目内容https://leetcode-cn.com/problems/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 max...原创 2019-04-11 19:28:23 · 116 阅读 · 0 评论 -
[LeetCode] 56. Merge Intervals
题目内容给出一个区间的集合,请合并所有重叠的区间。https://leetcode-cn.com/problems/merge-intervals/Given a collection of intervals, merge all overlapping intervals.Example 1:Input: [[1,3],[2,6],[8,10],[15,18]]Outp...原创 2019-04-11 20:09:44 · 96 阅读 · 0 评论 -
[LeetCode] 62. Unique Paths
题目内容一个机器人位于一个m x n网格的左上角 (起始点在下图中标记为“Start” )。机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角(在下图中标记为“Finish”)。问总共有多少条不同的路径?https://leetcode-cn.com/problems/unique-paths/A robot is located at the top-l...原创 2019-04-11 20:34:44 · 106 阅读 · 0 评论 -
*[LeetCode] 10.Regular Expression Matching
题目原文https://leetcode-cn.com/problems/regular-expression-matching/Given an input string (s) and a pattern (p), implement regular expression matching with support for'.'and'*'.'.' Matches any ...原创 2019-04-08 17:36:42 · 104 阅读 · 0 评论 -
[LeetCode] 11.Container With Most Water
题目内容给定 n 个非负整数 a1,a2,...,an,每个数代表坐标中的一个点(i,ai) 。在坐标内画 n 条垂直线,垂直线 i的两个端点分别为(i,ai) 和 (i, 0)。找出其中的两条线,使得它们与x轴共同构成的容器可以容纳最多的水。来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/container-with-...原创 2019-04-08 19:14:11 · 122 阅读 · 0 评论 -
[LeetCode] 96. Unique Binary Search Trees
题目内容https://leetcode-cn.com/problems/unique-binary-search-trees/Givenn, how many structurally uniqueBST's(binary search trees) that store values 1 ...n?Example:Input: 3Output: 5Explanat...原创 2019-04-15 16:41:12 · 83 阅读 · 0 评论 -
[LeetCode] 2.Add Two Numbers
题目内容给出两个非空 的链表用来表示两个非负的整数。其中,它们各自的位数是按照逆序的方式存储的,并且它们的每个节点只能存储一位数字。如果,我们将这两个数相加起来,则会返回一个新的链表来表示它们的和。您可以假设除了数字 0 之外,这两个数都不会以 0开头。https://leetcode-cn.com/problems/add-two-numbers/You are ...原创 2019-04-02 23:25:02 · 102 阅读 · 0 评论 -
[LeetCode] 1.Two Sum
题目内容给定一个整数数组nums和一个目标值target,请你在该数组中找出和为目标值的那两个整数,并返回他们的数组下标。你可以假设每种输入只会对应一个答案。但是,你不能重复利用这个数组中同样的元素。Given an array of integers, returnindicesof the two numbers such that they add up to a sp...原创 2019-04-02 22:59:40 · 146 阅读 · 0 评论 -
[LeetCode] 15. 3Sum
题目内容给定一个包含n个整数的数组nums,判断nums中是否存在三个元素a,b,c ,使得a + b + c =0 ?找出所有满足条件且不重复的三元组。注意:答案中不可以包含重复的三元组。https://leetcode-cn.com/problems/3sum/Given an arraynumsofnintegers, are there elemen...原创 2019-04-09 00:17:28 · 89 阅读 · 0 评论 -
[LeetCode] 3.Longest Substring Without Repeating Characters
题目内容给定一个字符串,请你找出其中不含有重复字符的最长子串的长度。Given a string, find the length of thelongest substringwithout repeating characters.https://leetcode-cn.com/problems/longest-substring-without-repeating-ch...原创 2019-04-03 14:03:39 · 99 阅读 · 0 评论 -
[LeetCode] 4.Median of Two Sorted Arrays
题目内容给定两个大小为 m 和 n 的有序数组nums1和nums2。请你找出这两个有序数组的中位数,并且要求算法的时间复杂度为O(log(m + n))。你可以假设nums1和nums2不会同时为空。https://leetcode-cn.com/problems/median-of-two-sorted-arrays/There are two sorted ...原创 2019-04-03 14:33:47 · 101 阅读 · 0 评论 -
[LeetCode] 17. Letter Combinations of a Phone Number
题目内容给定一个仅包含数字2-9的字符串,返回所有它能表示的字母组合。给出数字到字母的映射如下(与电话按键相同)。注意 1 不对应任何字母。https://leetcode-cn.com/problems/letter-combinations-of-a-phone-number/Given a string containing digits from2-9inclusiv...原创 2019-04-09 17:57:07 · 94 阅读 · 0 评论 -
[LeetCode] 19. Remove Nth Node From End of List
题目内容给定一个链表,删除链表的倒数第n个节点,并且返回链表的头结点。Given a linked list, remove then-th node from the end of list and return its head.https://leetcode-cn.com/problems/remove-nth-node-from-end-of-list/Examp...原创 2019-04-09 18:21:29 · 92 阅读 · 0 评论 -
[LeetCode] 20. Valid Parentheses
题目内容给定一个只包括'(',')','{','}','[',']'的字符串,判断字符串是否有效。有效字符串需满足:左括号必须用相同类型的右括号闭合。 左括号必须以正确的顺序闭合。注意空字符串可被认为是有效字符串。https://leetcode-cn.com/problems/valid-parentheses/Given a string containing ju...原创 2019-04-09 18:41:41 · 99 阅读 · 0 评论 -
[LeetCode] 21. Merge Two Sorted Lists
题目内容将两个有序链表合并为一个新的有序链表并返回。新链表是通过拼接给定的两个链表的所有节点组成的。Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.E...原创 2019-04-09 18:49:43 · 109 阅读 · 0 评论 -
[LeetCode] 64. Minimum Path Sum
题目内容https://leetcode-cn.com/problems/minimum-path-sum/Given amxngrid filled with non-negative numbers, find a path from top left to bottom right whichminimizesthe sum of all numbers along it...原创 2019-04-13 11:17:35 · 97 阅读 · 0 评论 -
[LeetCode] 70. Climbing Stairs
题目内容https://leetcode-cn.com/problems/climbing-stairs/You are climbing a stair case. It takesnsteps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can...原创 2019-04-13 11:27:12 · 114 阅读 · 0 评论 -
[LeetCode] 22. Generate Parentheses
题目内容https://leetcode-cn.com/problems/generate-parentheses/Givennpairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solu...原创 2019-04-09 21:39:51 · 128 阅读 · 0 评论 -
[LeetCode] 23. Merge k Sorted Lists
题目内容合并k个排序链表,返回合并后的排序链表。请分析和描述算法的复杂度。https://leetcode-cn.com/problems/merge-k-sorted-lists/Mergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity....原创 2019-04-09 21:52:38 · 93 阅读 · 0 评论 -
[LeetCode] 32. Longest Valid Parentheses
题目内容Given a string containing just the characters'('and')', find the length of the longest valid (well-formed) parentheses substring.Example 1:Input: "(()"Output: 2Explanation: The longest...原创 2019-04-09 22:50:03 · 81 阅读 · 0 评论 -
[LeetCode] 33. Search in Rotated Sorted Array
题目内容https://leetcode-cn.com/problems/search-in-rotated-sorted-array/Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e.,[0,1,2,4,5,6,7]might bec...原创 2019-04-09 23:26:00 · 84 阅读 · 0 评论 -
[LeetCode] 34. Find First and Last Position of Element in Sorted Array
题目内容https://leetcode-cn.com/problems/find-first-and-last-position-of-element-in-sorted-array/Given an array of integersnumssorted in ascending order, find the starting and ending position of a g...原创 2019-04-09 23:41:12 · 96 阅读 · 0 评论 -
[LeetCode] 72. Edit Distance
题目内容https://leetcode-cn.com/problems/edit-distance/Given two wordsword1andword2, find the minimum number of operations required to convertword1toword2.You have the following 3 operations p...原创 2019-04-13 11:57:52 · 91 阅读 · 0 评论 -
[LeetCode] 75. Sort Colors
题目内容Given an array withnobjects colored red, white or blue, sort themin-placeso that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use ...原创 2019-04-13 12:38:33 · 122 阅读 · 0 评论 -
[LeetCode] 78. Subsets
题目内容给定一组不含重复元素的整数数组nums,返回该数组所有可能的子集(幂集)。https://leetcode-cn.com/problems/subsets/Given a set ofdistinctintegers,nums, return all possible subsets (the power set).Note:The solution set mu...原创 2019-04-14 12:43:33 · 111 阅读 · 0 评论 -
[LeetCode] 79. Word Search
题目内容https://leetcode-cn.com/problems/word-search/Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "a...原创 2019-04-14 13:22:46 · 107 阅读 · 0 评论 -
[LeetCode] 84. Largest Rectangle in Histogram
题目内容给定n个非负整数,用来表示柱状图中各个柱子的高度。每个柱子彼此相邻,且宽度为 1 。求在该柱状图中,能够勾勒出来的矩形的最大面积。Givennnon-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of la...原创 2019-04-14 15:21:46 · 106 阅读 · 0 评论 -
[LeetCode] 94. Binary Tree Inorder Traversal
题目内容https://leetcode-cn.com/problems/binary-tree-inorder-traversal/Given a binary tree, return theinordertraversal of its nodes' values.Example:Input: [1,null,2,3] 1 \ 2 / ...原创 2019-04-14 16:31:45 · 112 阅读 · 0 评论 -
[LeetCode] 102. Binary Tree Level Order Traversal
题目内容https://leetcode-cn.com/problems/binary-tree-level-order-traversal/Given a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).For ex...原创 2019-04-15 13:45:42 · 97 阅读 · 0 评论 -
[LeetCode] 101. Symmetric Tree
题目内容https://leetcode-cn.com/problems/symmetric-tree/Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree [1,2,2,3,4,4,3] i...原创 2019-04-15 14:27:56 · 92 阅读 · 0 评论 -
[LeetCode] 100. Same Tree
题目内容https://leetcode-cn.com/problems/same-tree/Given two binary trees, write a function to check if they are the same or not.Two binary trees are considered the same if they are structurally ide...原创 2019-04-15 14:52:00 · 87 阅读 · 0 评论 -
[LeetCode] 98. Validate Binary Search Tree
题目内容https://leetcode-cn.com/problems/validate-binary-search-tree/Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of...原创 2019-04-15 15:10:46 · 89 阅读 · 0 评论