- 博客(14)
- 收藏
- 关注
原创 Leetcode 85. Maximal Rectangle
QuestionGiven a 2D binary matrix filled with 0’s and 1’s, find the largest rectangle containing all ones and return its area.Code public int maximalRectangle(char[][] matrix) { if (matrix == nu
2016-04-10 21:10:11 319
原创 leetcode 84. Largest Rectangle in Histogram
QuestionGiven n non-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 of e
2016-04-10 20:28:44 312
原创 Leetcode 86. Partition List
QuestionGiven a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative order of the nodes in each
2016-04-06 13:38:53 520
原创 Leetcode 87. Scramble String
QuestionGiven a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation of s1 = “great”: great / \ gr
2016-04-06 13:31:44 295
原创 Leetcode 89. Gray Code
QuestionThe gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total number of bits in the code, print the sequence
2016-04-06 10:37:14 432
原创 Leetcode 99. Recover Binary Search Tree
QuestionTwo elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Code TreeNode pre = null; TreeNode first = null; TreeNode second = null
2016-04-05 19:19:17 234
原创 Leetcode 96. Unique Binary Search Trees
QuestionGiven n, how many structurally unique BST’s (binary search trees) that store values 1…n?For example, Given n = 3, there are a total of 5 unique BST’s. 1 3 3 2 1 \
2016-04-05 19:10:51 510
原创 Leetcode 95. Unique Binary Search Trees II
QuestionGiven n, generate all structurally unique BST’s (binary search trees) that store values 1…n.For example, Given n = 3, your program should return all 5 unique BST’s shown below. 1 3
2016-04-05 19:08:54 442
原创 leetcode 94. Binary Tree Inorder Traversal
QuestionGiven a binary tree, return the inorder traversal of its nodes’ values.For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,3,2].Code public void get(TreeNode root, Li
2016-04-05 18:45:55 219
原创 Leetcode 93. Restore IP Addresses
QuestionGiven a string containing only digits, restore it by returning all possible valid IP address combinations.For example: Given “25525511135”,return [“255.255.11.135”, “255.255.111.35”]. (Order d
2016-04-05 18:43:43 221
原创 Leetcode 92. Reverse Linked List II
QuestionReverse a linked list from position m to n. Do it in-place and in one-pass.For example: Given 1->2->3->4->5->NULL, m = 2 and n = 4,return 1->4->3->2->5->NULL.Note: Given m, n satisfy the foll
2016-04-05 18:15:49 290
原创 leetcode 91. Decode Ways
QuestionA message containing letters from A-Z is being encoded to numbers using the following mapping:‘A’ -> 1 ‘B’ -> 2 … ‘Z’ -> 26 Given an encoded message containing digits, determine the total n
2016-04-05 16:40:58 394
原创 Leetcode 90. Subsets II
QuestionGiven a collection of integers that might contain duplicates, nums, return all possible subsets.Note: Elements in a subset must be in non-descending order. The solution set must not contain d
2016-04-05 16:13:05 205
原创 Leetcode 78. Subsets
QuestionGiven a set of distinct integers, nums, return all possible subsets.Note: Elements in a subset must be in non-descending order. The solution set must not contain duplicate subsets. For examp
2016-04-05 15:51:16 226
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人