
LeetCode
文章平均质量分 68
Ethan95
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
【LeetCode】54. Spiral Matrix(C++)
地址:https://leetcode.com/problems/spiral-matrix/题目:Given a matrix of mxnm x nmxn elements (mmm rows, nnn columns), return all elements of the matrix in spiral order.Example 1:Example 2:理解:按规则走一...原创 2018-11-30 14:24:21 · 375 阅读 · 0 评论 -
【LeetCode】63. Unique Paths II(C++)
地址:https://leetcode.com/problems/unique-paths-ii/题目:A robot is located at the top-left corner of a m∗nm * nm∗n grid (marked ‘Start’ in the diagram below).The robot can only move either down or righ...原创 2018-12-04 09:15:36 · 378 阅读 · 0 评论 -
【LeetCode】64. Minimum Path Sum(C++)
地址:https://leetcode.com/problems/minimum-path-sum/题目:Given a m∗nm * nm∗n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along...原创 2018-12-04 09:32:04 · 248 阅读 · 0 评论 -
【LeetCode】81. Search in Rotated Sorted Array II(C++)
地址:https://leetcode.com/problems/search-in-rotated-sorted-array-ii/题目:Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., [0,0,1,2,2,5,6] might beco...原创 2018-12-09 10:23:57 · 254 阅读 · 0 评论 -
【LeetCode】92. Reverse Linked List II(C++)
地址:https://leetcode.com/problems/reverse-linked-list-ii/题目:Reverse a linked list from position m to n. Do it in one-pass.Note: 1 ≤ m ≤ n ≤ length of list.Example:Input: 1->2->3->4->5...原创 2018-12-14 10:23:41 · 276 阅读 · 0 评论 -
【LeetCode】93. Restore IP Addresses(C++)
地址:https://leetcode.com/problems/restore-ip-addresses/题目:Given a string containing only digits, restore it by returning all possible valid IP address combinations.Example:Input: “25525511135”Out...原创 2018-12-14 11:31:16 · 323 阅读 · 0 评论 -
【LeetCode】77. Combinations(C++)
地址:https://leetcode.com/problems/combinations/题目:Given two integers n and k, return all possible combinations of k numbers out of 1 … n.Example:理解:很像前面的permutation还有combinatio sum的问题,用backtracki...原创 2018-12-07 09:38:08 · 284 阅读 · 0 评论 -
【LeetCode】78. Subsets(C++)
地址:https://leetcode.com/problems/subsets/题目:Given a set of distinct integers, numsnumsnums, return all possible subsets (the power set).Note: The solution set must not contain duplicate subsets.Ex...原创 2018-12-07 09:59:48 · 342 阅读 · 0 评论 -
【LeetCode】82. Remove Duplicates from Sorted List II(C++)
地址:https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/题目:Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original li...原创 2018-12-09 11:41:34 · 200 阅读 · 0 评论 -
【LeetCode】75. Sort Colors(C++)
地址:https://leetcode.com/problems/sort-colors/题目:Given an array with n objects colored red, white or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the or...原创 2018-12-06 10:51:06 · 213 阅读 · 0 评论 -
【LeetCode】74. Search a 2D Matrix(C++)
地址:https://leetcode.com/problems/search-a-2d-matrix/题目:Write an efficient algorithm that searches for a value in an mmm x nnn matrix. This matrix has the following properties:Integers in each row ...原创 2018-12-06 10:11:03 · 597 阅读 · 0 评论 -
【LeetCode】55. Jump Game(C++)
地址:https://leetcode.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 maximum...原创 2018-12-01 10:33:05 · 307 阅读 · 0 评论 -
【LeetCode】56. Merge Intervals(C++)
地址:https://leetcode.com/problems/jump-game/题目:https://leetcode.com/problems/merge-intervals/Example 1:Example 2:理解:在有序的情况下,直接从头到尾和并一次就可以了。实现:在排序的时候,end的大小其实是不重要的。class Solution {public: v...原创 2018-12-01 11:18:53 · 331 阅读 · 0 评论 -
【LeetCode】61. Rotate List(C++)
地址:https://leetcode.com/problems/rotate-list/题目:Given a linked list, rotate the list to the right by kkk places, where kkk is non-negative.Example 1:Input: 1->2->3->4->5->NULL, k =...原创 2018-12-03 09:01:18 · 240 阅读 · 0 评论 -
【LeetCode】71. Simplify Path(C++)
地址:https://leetcode.com/problems/simplify-path/题目:Given an absolute path for a file (Unix-style), simplify it.For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c"path =...原创 2018-12-05 09:27:33 · 263 阅读 · 0 评论 -
【LeetCode】73. Set Matrix Zeroes(C++)
地址:https://leetcode.com/problems/set-matrix-zeroes/题目:Given a mmm x nnn matrix, if an element is 0, set its entire row and column to 0. Do it in-place.Example 1:Example 2:Follow up:A straight...原创 2018-12-05 16:05:29 · 353 阅读 · 0 评论 -
【LeetCode】62. Unique Paths(C++)
地址:https://leetcode.com/problems/unique-paths/题目:A robot is located at the top-left corner of a m∗nm * nm∗n grid (marked ‘Start’ in the diagram below).The robot can only move either down or right a...原创 2018-12-03 10:44:04 · 246 阅读 · 0 评论 -
【LeetCode】79. Word Search(C++)
地址:https://leetcode.com/problems/subsets/题目: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 “adjacent”...原创 2018-12-08 09:13:21 · 320 阅读 · 0 评论 -
【LeetCode】80. Remove Duplicates from Sorted Array II(C++)
地址:https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii/题目:Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twice and return the new le...原创 2018-12-08 09:32:48 · 159 阅读 · 0 评论 -
【LeetCode】94. Binary Tree Inorder Traversal(C++)
地址:https://leetcode.com/problems/restore-ip-addresses/题目:Given a binary tree, return the inorder traversal of its nodes’ values.Example:理解:二叉树的中序遍历递归实现:class Solution {public: vector<int&...原创 2018-12-15 09:33:22 · 265 阅读 · 0 评论 -
【LeetCode】96. Unique Binary Search Trees(C++)
地址:https://leetcode.com/problems/unique-binary-search-trees/题目:Given nnn, how many structurally unique BST’s (binary search trees) that store values 1...n1 ... n1...n?Example:理解:就是要求n个数的二叉排序树的个数...原创 2018-12-15 09:54:59 · 181 阅读 · 0 评论 -
【LeetCode】86. Partition List(C++)
地址:https://leetcode.com/problems/partition-list/题目:Given a linked list and a value xxx, partition it such that all nodes less than xxx come before nodes greater than or equal to xxx.You should pres...原创 2018-12-10 09:06:59 · 281 阅读 · 0 评论 -
【LeetCode】45. Jump Game II(C++)
地址:https://leetcode.com/problems/jump-game-ii/题目: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 maxi...原创 2018-12-27 21:42:03 · 259 阅读 · 0 评论 -
【LeetCode】442. Find All Duplicates in an Array(C++)
地址:https://leetcode.com/problems/find-all-duplicates-in-an-array/题目:Given an array of integers, 1 ≤ a[i] ≤ nnn (nnn = size of array), some elements appear twice and others appear once.Find all the ...原创 2018-12-28 10:15:52 · 203 阅读 · 0 评论 -
【LeetCode】4. Median of Two Sorted Arrays(C++)
地址:https://leetcode.com/problems/median-of-two-sorted-arrays/题目:There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run ti...原创 2018-12-19 10:00:08 · 258 阅读 · 0 评论 -
【LeetCode】72. Edit Distance(C++)
地址:https://leetcode.com/problems/edit-distance/题目:Given two words word1 and word2, find the minimum number of operations required to convert word1 to word2.You have the following 3 operations permi...原创 2018-12-29 21:51:20 · 308 阅读 · 0 评论 -
【LeetCode】76. Minimum Window Substring(C++)
地址:https://leetcode.com/problems/minimum-window-substring/题目:Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n)O(n)O(n).Exam...原创 2018-12-31 11:36:13 · 351 阅读 · 0 评论 -
【LeetCode】42. Trapping Rain Water(C++)
地址:https://leetcode.com/problems/trapping-rain-water/题目:Given nnn non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap afte...原创 2018-12-26 10:00:33 · 456 阅读 · 0 评论 -
【LeetCode】84. Largest Rectangle in Histogram(C++)
地址:https://leetcode.com/problems/largest-rectangle-in-histogram/题目:Given nnn non-negative integers representing the histogram’s bar height where the width of each bar is 1, find the area of largest ...原创 2019-01-01 12:05:11 · 330 阅读 · 0 评论 -
【LeetCode】85. Maximal Rectangle(C++)
地址:https://leetcode.com/problems/maximal-rectangle/题目:Given a 2D binary matrix filled with 0’s and 1’s, find the largest rectangle containing only 1’s and return its area.Example:理解:找出给定的矩阵里全1的矩...原创 2019-01-02 11:05:33 · 390 阅读 · 0 评论 -
【LeetCode】696. Count Binary Substrings(C++)
地址:https://leetcode.com/problems/count-binary-substrings/题目:Give a string s, count the number of non-empty (contiguous) substrings that have the same number of 0’s and 1’s, and all the 0’s and all t...原创 2018-12-27 19:54:45 · 259 阅读 · 0 评论 -
【LeetCode】32. Longest Valid Parentheses(C++)
地址:https://leetcode.com/problems/longest-valid-parentheses/题目:Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.Exa...原创 2018-12-22 11:00:47 · 261 阅读 · 0 评论 -
【LeetCode】89. Gray Code(C++)
地址:https://leetcode.com/problems/gray-code/题目:The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer nnn representing the total num...原创 2018-12-10 10:24:21 · 331 阅读 · 0 评论 -
【LeetCode】95. Unique Binary Search Trees II(C++)
地址:https://leetcode.com/problems/unique-binary-search-trees-ii/题目:Given an integer nnn, generate all structurally unique BST’s (binary search trees) that store values 111 … nnn.Example:理解:上一道题求的...原创 2018-12-16 11:06:14 · 790 阅读 · 1 评论 -
【LeetCode】98. Validate Binary Search Tree(C++)
地址:https://leetcode.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 a n...原创 2018-12-16 11:50:08 · 451 阅读 · 0 评论 -
【LeetCode】10. Regular Expression Matching(C++)
地址:https://leetcode.com/problems/regular-expression-matching/题目:Given an input string (s) and a pattern (p), implement regular expression matching with support for '.' and '*'.‘.’ Matches any sing...原创 2018-12-21 12:37:31 · 367 阅读 · 0 评论 -
【LeetCode】30. Substring with Concatenation of All Words(C++)
地址:https://leetcode.com/problems/substring-with-concatenation-of-all-words/题目:You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of sub...原创 2018-12-27 16:07:43 · 326 阅读 · 0 评论 -
【LeetCode】90. Subsets II(C++)
地址:https://leetcode.com/problems/gray-code/题目:Given a collection of integers that might contain duplicates, nums, return all possible subsets (the power set).Note: The solution set must not contain...原创 2018-12-11 09:04:04 · 258 阅读 · 0 评论 -
【LeetCode】91. Decode Ways(C++)
地址:https://leetcode.com/problems/decode-ways/题目:A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given a non-e...原创 2018-12-11 09:52:25 · 496 阅读 · 0 评论 -
【LeetCode】23. Merge k Sorted Lists(C++)
地址:https://leetcode.com/problems/merge-k-sorted-lists/题目:Merge kkk sorted linked lists and return it as one sorted list. Analyze and describe its complexity.Example:理解:合并k个有序链表。想到了外部排序里面的败者数,其本质...原创 2018-12-22 09:30:32 · 520 阅读 · 0 评论