摘要:
题目: Follow up for problem "Populating Next Right Pointers in Each Node". What if the given tree could be any binary tree? Would your previous solution 阅读全文
posted @ 2015-04-18 15:19
YRB
阅读(1163)
评论(0)
推荐(0)
摘要:
题目: Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate each next pointer to point to it 阅读全文
posted @ 2015-04-18 14:03
YRB
阅读(1249)
评论(0)
推荐(0)
摘要:
题目:Given a stringSand a stringT, count the number of distinct subsequences ofTinS.A subsequence of a string is a new string which is formed from the o... 阅读全文
posted @ 2015-04-18 14:02
YRB
阅读(310)
评论(0)
推荐(0)
摘要:
题目: Given a binary tree, flatten it to a linked list in-place. For example,Given The flattened tree should look like: click to show hints. Hints: If y 阅读全文
posted @ 2015-04-18 14:01
YRB
阅读(686)
评论(0)
推荐(0)
摘要:
题目: Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. return 链接: http://leetcode.com/problems/pat 阅读全文
posted @ 2015-04-18 13:59
YRB
阅读(616)
评论(0)
推荐(0)
摘要:
题目: Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given su 阅读全文
posted @ 2015-04-18 13:58
YRB
阅读(706)
评论(0)
推荐(0)
摘要:
题目: Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the neare 阅读全文
posted @ 2015-04-18 13:57
YRB
阅读(1282)
评论(0)
推荐(0)
摘要:
题目: Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a binary tree in which the 阅读全文
posted @ 2015-04-18 13:56
YRB
阅读(778)
评论(0)
推荐(0)
摘要:
题目: Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. 链接: http://leetcode.com/problems/con 阅读全文
posted @ 2015-04-18 13:54
YRB
阅读(1373)
评论(0)
推荐(0)
摘要:
题目: Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 链接: http://leetcode.com/problems/convert-sorted- 阅读全文
posted @ 2015-04-18 13:51
YRB
阅读(1086)
评论(0)
推荐(0)
摘要:
题目: Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root). 阅读全文
posted @ 2015-04-18 13:47
YRB
阅读(563)
评论(0)
推荐(0)
摘要:
题目: Given inorder and postorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. 链接: http 阅读全文
posted @ 2015-04-18 13:46
YRB
阅读(607)
评论(0)
推荐(0)
摘要:
题目: Given preorder and inorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. 链接: http: 阅读全文
posted @ 2015-04-18 13:41
YRB
阅读(621)
评论(0)
推荐(0)
摘要:
题目: 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 farthe 阅读全文
posted @ 2015-04-18 13:40
YRB
阅读(908)
评论(0)
推荐(0)
摘要:
题目: Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level 阅读全文
posted @ 2015-04-18 13:39
YRB
阅读(446)
评论(0)
推荐(0)
摘要:
题目: Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example:Given binary tre 阅读全文
posted @ 2015-04-18 13:38
YRB
阅读(424)
评论(0)
推荐(1)
摘要:
题目: Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree is symmetric: But the 阅读全文
posted @ 2015-04-18 12:24
YRB
阅读(417)
评论(0)
推荐(0)
摘要:
题目: Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identic 阅读全文
posted @ 2015-04-18 12:23
YRB
阅读(375)
评论(0)
推荐(0)
摘要:
题目:Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A solution using O(n) space ... 阅读全文
posted @ 2015-04-18 12:22
YRB
阅读(637)
评论(0)
推荐(0)
摘要:
题目: Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: 链接:http://leetcode.com/problems/vali 阅读全文
posted @ 2015-04-18 12:21
YRB
阅读(1102)
评论(0)
推荐(0)
摘要:
题目:Givens1,s2,s3, find whethers3is formed by the interleaving ofs1ands2.For example,Given:s1="aabcc",s2="dbbca",Whens3="aadbbcbcac", return true.Whens... 阅读全文
posted @ 2015-04-18 12:20
YRB
阅读(439)
评论(0)
推荐(0)
摘要:
题目: Given 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 阅读全文
posted @ 2015-04-18 12:19
YRB
阅读(408)
评论(0)
推荐(0)
摘要:
题目: Given n, generate all structurally unique BST's (binary search trees) that store values 1...n. For example,Given n = 3, your program should return 阅读全文
posted @ 2015-04-18 12:17
YRB
阅读(882)
评论(0)
推荐(0)
摘要:
题目: Given a binary tree, return the inorder traversal of its nodes' values. For example:Given binary tree {1,#,2,3}, return [1,3,2]. 链接: http://leetco 阅读全文
posted @ 2015-04-18 12:16
YRB
阅读(537)
评论(0)
推荐(0)
摘要:
题目: Given a string containing only digits, restore it by returning all possible valid IP address combinations. For example:Given "25525511135", return 阅读全文
posted @ 2015-04-18 12:15
YRB
阅读(854)
评论(0)
推荐(0)
摘要:
题目: Reverse 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 阅读全文
posted @ 2015-04-18 12:13
YRB
阅读(558)
评论(0)
推荐(0)
摘要:
题目: A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' -> 1 'B' -> 2 ... 'Z' -> 26 Given an encoded me 阅读全文
posted @ 2015-04-18 12:11
YRB
阅读(635)
评论(1)
推荐(0)
摘要:
题目: Given a collection of integers that might contain duplicates, nums, return all possible subsets. Note: Elements in a subset must be in non-descend 阅读全文
posted @ 2015-04-18 12:10
YRB
阅读(747)
评论(0)
推荐(0)
摘要:
题目: The 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 阅读全文
posted @ 2015-04-18 12:09
YRB
阅读(547)
评论(0)
推荐(0)
摘要:
题目: Given two sorted integer arrays A and B, merge B into A as one sorted array. Note:You may assume that A has enough space (size that is greater or 阅读全文
posted @ 2015-04-18 12:08
YRB
阅读(350)
评论(0)
推荐(0)
摘要:
题目: Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively. Below is one possible represen 阅读全文
posted @ 2015-04-18 12:07
YRB
阅读(633)
评论(0)
推荐(0)
摘要:
题目: Given 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 阅读全文
posted @ 2015-04-18 12:06
YRB
阅读(363)
评论(0)
推荐(0)
摘要:
题目: Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area. 链接: http://leetcode.com/prob 阅读全文
posted @ 2015-04-18 12:05
YRB
阅读(743)
评论(0)
推荐(0)
摘要:
题目: Given 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 阅读全文
posted @ 2015-04-18 12:04
YRB
阅读(551)
评论(0)
推荐(0)
摘要:
题目: Given a sorted linked list, delete all duplicates such that each element appear only once. For example,Given 1->1->2, return 1->2.Given 1->1->2->3 阅读全文
posted @ 2015-04-18 12:03
YRB
阅读(207)
评论(0)
推荐(0)
摘要:
题目: Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. For example,Given 阅读全文
posted @ 2015-04-18 12:02
YRB
阅读(234)
评论(0)
推荐(0)
摘要:
题目: Follow up for "Search in Rotated Sorted Array":What if duplicates are allowed? Would this affect the run-time complexity? How and why? Write a fun 阅读全文
posted @ 2015-04-18 12:01
YRB
阅读(312)
评论(0)
推荐(0)
摘要:
题目: Follow up for "Remove Duplicates":What if duplicates are allowed at most twice? For example,Given sorted array nums = [1,1,1,2,2,3], Your function 阅读全文
posted @ 2015-04-18 12:00
YRB
阅读(279)
评论(0)
推荐(0)
摘要:
题目: 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 阅读全文
posted @ 2015-04-18 11:59
YRB
阅读(1653)
评论(0)
推荐(1)
摘要:
题目: Given a set of distinct integers, S, return all possible subsets. Note: Elements in a subset must be in non-descending order. The solution set mus 阅读全文
posted @ 2015-04-18 11:58
YRB
阅读(756)
评论(0)
推荐(0)
摘要:
题目: Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For example,If n = 4 and k = 2, a solution is: [ [2,4], 阅读全文
posted @ 2015-04-18 11:57
YRB
阅读(1097)
评论(0)
推荐(0)
摘要:
题目: 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). For example,S = "ADOB 阅读全文
posted @ 2015-04-18 11:55
YRB
阅读(369)
评论(0)
推荐(0)
摘要:
题目: Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order r 阅读全文
posted @ 2015-04-18 11:54
YRB
阅读(316)
评论(0)
推荐(0)
摘要:
题目: Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sort 阅读全文
posted @ 2015-04-18 11:53
YRB
阅读(225)
评论(0)
推荐(0)
摘要:
题目: Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. 链接: http://leetcode.com/problems/set-matrix-zeroes/ 阅读全文
posted @ 2015-04-18 11:52
YRB
阅读(333)
评论(0)
推荐(0)
摘要:
题目: Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) You h 阅读全文
posted @ 2015-04-18 11:50
YRB
阅读(480)
评论(0)
推荐(0)
摘要:
题目: Given an absolute path for a file (Unix-style), simplify it. For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c" click to sho 阅读全文
posted @ 2015-04-18 11:49
YRB
阅读(329)
评论(0)
推荐(0)
摘要:
题目: You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can yo 阅读全文
posted @ 2015-04-18 00:17
YRB
阅读(305)
评论(0)
推荐(0)
摘要:
题目: Implement int sqrt(int x). Compute and return the square root of x. 链接: http://leetcode.com/problems/sqrtx/ 题解: 求平方根。 二分法, Time Complexity - O(log 阅读全文
posted @ 2015-04-18 00:12
YRB
阅读(572)
评论(0)
推荐(0)
摘要:
题目: Given an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) justified. You 阅读全文
posted @ 2015-04-18 00:09
YRB
阅读(458)
评论(0)
推荐(0)
摘要:
题目: Given two binary strings, return their sum (also a binary string). For example,a = "11"b = "1"Return "100". 链接: http://leetcode.com/problems/add-b 阅读全文
posted @ 2015-04-18 00:08
YRB
阅读(416)
评论(0)
推荐(0)
摘要:
题目: Given a non-negative number represented as an array of digits, plus one to the number. The digits are stored such that the most significant digit 阅读全文
posted @ 2015-04-18 00:07
YRB
阅读(308)
评论(0)
推荐(0)

浙公网安备 33010602011771号