- 博客(282)
- 收藏
- 关注
转载 19.3.5 [LeetCode 106] Construct Binary Tree from Inorder and Postorder Traversal
Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.For example, giveninorder =[9,3,15,20,7]postorder ...
2019-03-05 11:22:00
236
转载 19.3.5 [LeetCode 105] Construct Binary Tree from Preorder and Inorder Traversal
Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.For example, givenpreorder =[3,9,20,15,7]inorder = ...
2019-03-05 11:08:00
247
转载 19.3.5 [LeetCode 104] Maximum Depth of Binary Tree
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.Note:A leaf is a node with no ch...
2019-03-05 10:41:00
212
转载 19.3.5 [LeetCode 103] Binary Tree Zigzag Level Order Traversal
Given a binary tree, return thezigzag level ordertraversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).For example:Given binary...
2019-03-05 10:35:00
123
转载 19.3.4 [LeetCode 102] 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 example:Given binary tree[3,9,20,null,null,15,7], 3 / \ 9 ...
2019-03-04 22:42:00
99
转载 19.3.2 [LeetCode 101] 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]is symmetric: 1 / \ 2 2 / \ / \3 4...
2019-03-02 13:34:00
97
转载 19.3.2 [LeetCode 99] Recover Binary Search Tree
Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Example 1:Input: [1,3,null,null,2] 1 /3 \ 2Output: [...
2019-03-02 13:18:00
99
转载 19.3.2 [LeetCode 98] 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 node contains only nodes with keysless thanthe node's key...
2019-03-02 11:26:00
90
转载 19.2.27 [LeetCode 97] Interleaving String
Givens1,s2,s3, find whethers3is formed by the interleaving ofs1ands2.Example 1:Input: s1 = "aabcc", s2 = "dbbca", s3 = "aadbbcbcac"Output: trueExample 2:Input: s1 = "aabcc", s...
2019-02-27 20:15:00
91
转载 19.2.27 [LeetCode 96] Unique Binary Search Trees
Givenn, how many structurally uniqueBST's(binary search trees) that store values 1 ...n?Example:Input: 3Output: 5Explanation:Given n = 3, there are a total of 5 unique BST's: ...
2019-02-27 18:22:00
91
转载 19.2.24 [LeetCode 95] Unique Binary Search Trees II
Given an integern, generate all structurally uniqueBST's(binary search trees) that store values 1 ...n.Example:Input: 3Output:[ [1,null,3,2], [3,2,null,1], [3,1,null,null,2],...
2019-02-24 22:08:00
120
转载 19.2.24 [LeetCode 94] Binary Tree Inorder Traversal
Given a binary tree, return theinordertraversal of its nodes' values.Example:Input: [1,null,2,3] 1 \ 2 / 3Output: [1,3,2] 1 class Solution { 2 public: ...
2019-02-24 21:39:00
85
转载 19.2.24 [LeetCode 92] Reverse Linked List II
Reverse a linked list from positionmton. Do it in one-pass.Note:1 ≤m≤n≤ length of list.Example:Input: 1->2->3->4->5->NULL, m = 2, n = 4Output: 1->4->3->2-&...
2019-02-24 21:29:00
79
转载 19.2.23 [LeetCode 91] Decode Ways
A message containing letters fromA-Zis being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given anon-emptystring containing only digits, det...
2019-02-23 19:16:00
93
转载 19.2.23 [LeetCode 90] Subsets II
Given a collection of integers that might contain duplicates,nums, return all possible subsets (the power set).Note:The solution set must not contain duplicate subsets.Example:Input: [1,2...
2019-02-23 17:01:00
95
转载 19.2.23 [LeetCode 89] Gray Code
The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integernrepresenting the total number of bits in the code, print the sequence ...
2019-02-23 13:50:00
108
转载 19.2.23 [LeetCode 87] Scramble String
Given a strings1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation ofs1="great": great / \ ...
2019-02-23 10:57:00
123
转载 19.2.23 [LeetCode 86] Partition List
Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve the original relative order of the nodes in each...
2019-02-23 09:37:00
85
转载 19.2.23 [LeetCode 85] 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:Input:[ ["1","0","1","0","0"], ["1","0","1","1","1"], [...
2019-02-23 09:20:00
92
转载 19.2.22 [LeetCode 84] Largest Rectangle in Histogram
Givennnon-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.Above is a histogram where width o...
2019-02-22 21:32:00
83
转载 19.2.21 [LeetCode 82] Remove Duplicates from Sorted List II
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list.Example 1:Input: 1->2->3->3->4->4->5Output: ...
2019-02-21 19:58:00
83
转载 19.2.19 [LeetCode 81] 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 become[2,5,6,0,0,1,2]).You are given a target value to search. If f...
2019-02-19 09:28:00
87
转载 19.2.15 [LeetCode 80] Remove Duplicates from Sorted Array II
Given a sorted arraynums, remove the duplicatesin-placesuch that duplicates appeared at mosttwiceand return the new length.Do not allocate extra space for another array, you must do this b...
2019-02-15 17:49:00
81
转载 19.2.15 [LeetCode 79] 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 "adjacent" cells are those horizontally or vertica...
2019-02-15 17:20:00
84
转载 19.2.15 [LeetCode 78] Subsets
Given a set ofdistinctintegers,nums, return all possible subsets (the power set).Note:The solution set must not contain duplicate subsets.Example:Input: nums = [1,2,3]Output:[ [3...
2019-02-15 16:13:00
76
转载 19.2.15 [LeetCode 77] Combinations
Given two integersnandk, return all possible combinations ofknumbers out of 1 ...n.Example:Input:n = 4, k = 2Output:[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4],]...
2019-02-15 15:45:00
81
转载 19.2.15 [LeetCode 76] 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).Example:Input: S = "ADOBECODEBANC", T = "ABC"Output: "BANC"No...
2019-02-15 15:16:00
75
转载 19.2.13 [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 t...
2019-02-13 20:41:00
114
转载 19.2.13 [LeetCode 74] Search a 2D Matrix
Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sorted from left to right.The first integer of e...
2019-02-13 20:13:00
90
转载 19.2.13 [LeetCode 73] Set Matrix Zeroes
Given amxnmatrix, if an element is 0, set its entire row and column to 0. Do itin-place.Example 1:Input: [ [1,1,1], [1,0,1], [1,1,1]]Output: [ [1,0,1], [0,0,0],...
2019-02-13 20:04:00
83
转载 19.2.13 [LeetCode 72] Edit Distance
Given two wordsword1andword2, find the minimum number of operations required to convertword1toword2.You have the following 3 operations permitted on a word:Insert a characterDelete ...
2019-02-13 19:40:00
94
转载 19.2.13 [LeetCode 71] Simplify Path
Given anabsolute pathfor a file (Unix-style), simplify it. Or in other words, convert it to thecanonical path.In a UNIX-style file system, a period.refers to the current directory. Further...
2019-02-13 18:23:00
85
转载 19.2.12 [LeetCode 70] 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 you climb to the top?Note:Givennwill be a pos...
2019-02-12 22:11:00
85
转载 19.2.12 [LeetCode 69] Sqrt(x)
Implementint sqrt(int x).Compute and return the square root ofx, wherexis guaranteed to be a non-negative integer.Since the return typeis an integer, the decimal digits are truncated and...
2019-02-12 22:04:00
82
转载 19.2.12 [LeetCode 68] Text Justification
Given an array of words and a widthmaxWidth, format the text such that each line has exactlymaxWidthcharacters and is fully (left and right) justified.You should pack your words in a greedy ...
2019-02-12 21:46:00
89
转载 19.2.12 [LeetCode 67] Add Binary
Given two binary strings, return their sum (also a binary string).The input strings are bothnon-emptyand contains only characters1or0.Example 1:Input: a = "11", b = "1"Output: "100"...
2019-02-12 20:02:00
85
转载 19.2.12 [LeetCode 66] Plus One
Given anon-emptyarray of digitsrepresenting a non-negative integer, plus one to the integer.The digits are stored such that the most significant digit is at the head of the list, and each el...
2019-02-12 17:39:00
96
转载 19.2.11 [LeetCode 64] 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 its path.Note:You can only move either down or right...
2019-02-11 11:14:00
120
转载 19.2.11 [LeetCode 63] Unique Paths II
A 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 point in time. The robot is trying to reach t...
2019-02-11 10:43:00
80
转载 19.2.9 [LeetCode 62] Unique Paths
A 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 point in time. The robot is trying to reach t...
2019-02-09 16:31:00
92
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人