
LeetCode
是三水不是泗水
只是个笔记本
展开
-
142. Linked List Cycle II
142.Linked List Cycle IIMedium1883150FavoriteShareGiven a linked list, return the node where the cycle begins. If there is no cycle, returnnull.To represent a cycle in the given linked li...原创 2019-11-29 22:48:04 · 123 阅读 · 0 评论 -
141. Linked List Cycle
141.Linked List CycleEasy1969284FavoriteShareGiven a linked list, determine if it has a cycle in it.To represent a cycle in the given linked list, we use an integerposwhich represents th...原创 2019-11-29 11:24:29 · 116 阅读 · 0 评论 -
139. Word Break
139.Word BreakMedium2987164FavoriteShareGiven anon-emptystringsand a dictionarywordDictcontaining a list ofnon-emptywords, determine ifscan be segmented into a space-separated sequ...原创 2019-11-28 19:48:50 · 108 阅读 · 0 评论 -
138. Copy List with Random Pointer
138.Copy List with Random PointerMedium2165531FavoriteShareA linked list is given such that each node contains an additional random pointer which could point to any node in the list or null....原创 2019-11-28 19:46:15 · 104 阅读 · 0 评论 -
136. Single Number
136.Single NumberEasy3087121FavoriteShareGiven anon-emptyarray of integers, every element appearstwiceexcept for one. Find that single one.Note:Your algorithm should have a linear runti...原创 2019-11-27 11:26:00 · 115 阅读 · 0 评论 -
128. Longest Consecutive Sequence
128.Longest Consecutive SequenceHard2363134FavoriteShareGiven an unsorted array of integers, find the length of the longest consecutive elements sequence.Your algorithm should run in O(n) ...原创 2019-11-27 10:45:52 · 131 阅读 · 0 评论 -
124. Binary Tree Maximum Path Sum
124.Binary Tree Maximum Path SumHard2263182FavoriteShareGiven anon-emptybinary tree, find the maximum path sum.For this problem, a path is defined as any sequence of nodes from some star...原创 2019-11-27 10:14:26 · 118 阅读 · 0 评论 -
114. Flatten Binary Tree to Linked List
114.Flatten Binary Tree to Linked ListMedium1926248FavoriteShareGiven a binary tree, flatten it to a linked list in-place.For example, given the following tree: 1 / \ 2 5 / \...转载 2019-11-19 22:25:54 · 90 阅读 · 0 评论 -
105. Construct Binary Tree from Preorder and Inorder Traversal
105.Construct Binary Tree from Preorder and Inorder TraversalMedium225462FavoriteShareGiven preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that du...原创 2019-11-19 09:48:08 · 97 阅读 · 0 评论 -
104. Maximum Depth of Binary Tree
104.Maximum Depth of Binary TreeEasy170062FavoriteShareGiven a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down t...原创 2019-11-18 22:07:20 · 99 阅读 · 1 评论 -
102. Binary Tree Level Order Traversal
102.Binary Tree Level Order TraversalMedium195352FavoriteShareGiven a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).For examp...原创 2019-11-18 11:21:01 · 98 阅读 · 0 评论 -
101. Symmetric Tree
101.Symmetric TreeEasy286066FavoriteShareGiven 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]is symm...原创 2019-11-18 11:04:44 · 174 阅读 · 0 评论 -
85. Maximal Rectangle
85.Maximal RectangleHard188155FavoriteShareGiven a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area.Example:Input:[ ["1","...原创 2019-11-18 10:30:04 · 95 阅读 · 0 评论 -
84. Largest Rectangle in Histogram
84.Largest Rectangle in HistogramHard249564FavoriteShareGivennnon-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest recta...原创 2019-11-17 22:23:31 · 97 阅读 · 0 评论 -
79. Word Search
79.Word SearchMedium2421130FavoriteShareGiven 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 "adja...原创 2019-11-16 10:36:41 · 113 阅读 · 0 评论 -
78. Subsets
78.SubsetsMedium254762FavoriteShareGiven a set ofdistinctintegers,nums, return all possible subsets (the power set).Note:The solution set must not contain duplicate subsets.Example:...原创 2019-11-16 09:44:09 · 105 阅读 · 1 评论 -
75. Sort Colors
75.Sort ColorsMedium2145181FavoriteShareGiven an array withnobjects colored red, white or blue, sort themin-placeso that objects of the same color are adjacent, with the colors in the or...原创 2019-11-14 12:47:30 · 89 阅读 · 0 评论 -
72. Edit Distance
72.Edit DistanceHard267741FavoriteShareGiven two wordsword1andword2, find the minimum number of operations required to convertword1toword2.You have the following 3 operations permitt...原创 2019-11-13 23:14:11 · 100 阅读 · 0 评论 -
70. Climbing Stairs
70.Climbing StairsEasy286098FavoriteShareYou 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 you ...原创 2019-11-12 14:45:08 · 114 阅读 · 0 评论 -
64. Minimum Path Sum
64.Minimum Path SumMedium175445FavoriteShareGiven amxngrid filled with non-negative numbers, find a path from top left to bottom right whichminimizesthe sum of all numbers along its pa...原创 2019-11-08 21:37:56 · 104 阅读 · 0 评论 -
62. Unique Paths
62.Unique PathsMedium2049151FavoriteShareA robot is located at the top-left corner of amxngrid (marked 'Start' in the diagram below).The robot can only move either down or right at any...原创 2019-11-07 11:03:18 · 123 阅读 · 0 评论 -
56. Merge Intervals
56.Merge IntervalsMedium2757219FavoriteShareGiven a collection of intervals, merge all overlapping intervals.Example 1:Input: [[1,3],[2,6],[8,10],[15,18]]Output: [[1,6],[8,10],[15,18]]...原创 2019-11-06 22:23:41 · 98 阅读 · 0 评论 -
55. Jump Game
55.Jump GameMedium2562244FavoriteShareGiven an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximu...原创 2019-11-05 11:24:53 · 100 阅读 · 0 评论 -
53. Maximum Subarray
53.Maximum SubarrayEasy5417226FavoriteShareGiven an integer arraynums, find the contiguous subarray(containing at least one number) which has the largest sum and return its sum.Example:...原创 2019-11-05 10:42:02 · 112 阅读 · 0 评论 -
49. Group Anagrams
49.Group AnagramsMedium2177134FavoriteShareGiven an array of strings, group anagrams together.Example:Input: ["eat", "tea", "tan", "ate", "nat", "bat"],Output:[ ["ate","eat","tea"],...原创 2019-11-05 09:46:21 · 99 阅读 · 0 评论 -
48. Rotate Image
48.Rotate ImageMedium2022179FavoriteShareYou are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Note:You have to rotate the imagein-place, w...原创 2019-11-04 11:13:16 · 137 阅读 · 0 评论 -
46. Permutations
46.PermutationsMedium261784FavoriteShareGiven a collection ofdistinctintegers, return all possible permutations.Example:Input: [1,2,3]Output:[ [1,2,3], [1,3,2], [2,1,3], [2,...原创 2019-11-04 10:10:36 · 165 阅读 · 0 评论 -
100. Same Tree
100.Same TreeEasy138245FavoriteShareGiven 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 identica...原创 2019-11-03 17:13:24 · 99 阅读 · 0 评论 -
99. Recover Binary Search Tree
99.Recover Binary Search TreeHard99658FavoriteShareTwo elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Example 1:Input: [...原创 2019-11-03 16:55:12 · 142 阅读 · 0 评论 -
98. Validate Binary Search Tree
98.Validate Binary Search TreeMedium2566373FavoriteShareGiven 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 ...原创 2019-11-03 16:29:47 · 97 阅读 · 0 评论 -
95. Unique Binary Search Trees II
95.Unique Binary Search Trees IIMedium1552129FavoriteShareGiven an integern, generate all structurally uniqueBST's(binary search trees) that store values 1 ...n.Example:Input: 3Out...原创 2019-11-02 21:46:07 · 128 阅读 · 0 评论 -
94. Binary Tree Inorder Traversal
94.Binary Tree Inorder TraversalMedium210093FavoriteShareGiven a binary tree, return theinordertraversal of its nodes' values.Example:Input: [1,null,2,3] 1 \ 2 / 3...原创 2019-11-02 20:31:09 · 91 阅读 · 0 评论 -
42. Trapping Rain Water
42.Trapping Rain WaterHard477683FavoriteShareGivennnon-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after rai...原创 2019-11-01 14:38:39 · 83 阅读 · 0 评论 -
41. First Missing Positive
41.First Missing PositiveHard2244664FavoriteShareGiven an unsorted integer array, find the smallest missingpositive integer.Example 1:Input: [1,2,0]Output: 3Example 2:Input: [3,...原创 2019-11-01 13:47:23 · 127 阅读 · 0 评论 -
39. Combination Sum
39.Combination SumMedium260179FavoriteShareGiven asetof candidate numbers (candidates)(without duplicates)and a target number (target), find all unique combinations incandidateswhere t...原创 2019-11-01 13:14:48 · 93 阅读 · 0 评论 -
34. Find First and Last Position of Element in Sorted Array
34.Find First and Last Position of Element in Sorted ArrayMedium2152100FavoriteShareGiven an array of integersnumssorted in ascending order, find the starting and ending position of a give...原创 2019-10-30 17:03:08 · 114 阅读 · 0 评论 -
33. Search in Rotated Sorted Array
33.Search in Rotated Sorted ArrayMedium3137371FavoriteShareSuppose 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 become...原创 2019-10-29 19:14:51 · 95 阅读 · 0 评论 -
32. Longest Valid Parentheses
32. Longest Valid ParenthesesHardGiven a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.Example 1:Input: "(()"...原创 2019-10-29 12:45:28 · 85 阅读 · 0 评论 -
31. Next Permutation
31. Next PermutationMediumImplement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rear...原创 2019-10-29 09:54:36 · 91 阅读 · 0 评论 -
23. Merge k Sorted Lists
23. Merge k Sorted ListsHardMerge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.Example:Input:[ 1->4->5, 1->3->4, 2->6]...原创 2019-10-28 21:56:37 · 85 阅读 · 0 评论