摘要: 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, 阅读全文
posted @ 2019-03-05 11:22 TobicYAL 阅读(331) 评论(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. For example, 阅读全文
posted @ 2019-03-05 11:08 TobicYAL 阅读(177) 评论(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 farthest l 阅读全文
posted @ 2019-03-05 10:41 TobicYAL 阅读(140) 评论(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 and 阅读全文
posted @ 2019-03-05 10:35 TobicYAL 阅读(197) 评论(-1) 推荐(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 tree [3 阅读全文
posted @ 2019-03-04 22:42 TobicYAL 阅读(161) 评论(0) 推荐(0) 编辑
摘要: 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 symmet 阅读全文
posted @ 2019-03-02 13:34 TobicYAL 阅读(150) 评论(0) 推荐(0) 编辑
摘要: Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without changing its structure. Example 1: Example 2: Follow up: A 阅读全文
posted @ 2019-03-02 13:18 TobicYAL 阅读(167) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2019-03-02 11:26 TobicYAL 阅读(210) 评论(0) 推荐(0) 编辑
摘要: Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. Example 1: Example 2: 题意 给出s1,s2,s3,判断是否能从s3中抽取出若干个字符以原顺序组成字符串和s1相等,并且s3 阅读全文
posted @ 2019-02-27 20:15 TobicYAL 阅读(163) 评论(0) 推荐(0) 编辑
摘要: Given n, how many structurally unique BST's (binary search trees) that store values 1 ... n? Example: 1 class Solution { 2 public: 3 vector<int>q; 4 i 阅读全文
posted @ 2019-02-27 18:22 TobicYAL 阅读(224) 评论(0) 推荐(0) 编辑
摘要: Given an integer n, generate all structurally unique BST's (binary search trees) that store values 1 ... n. Example: 题意 给定一数n,求1-n所组成的所有可能的BST树的集合 题解 阅读全文
posted @ 2019-02-24 22:08 TobicYAL 阅读(195) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, return the inorder traversal of its nodes' values. Example: 1 class Solution { 2 public: 3 void build(TreeNode*root, vector<int>& 阅读全文
posted @ 2019-02-24 21:39 TobicYAL 阅读(122) 评论(0) 推荐(0) 编辑
摘要: Reverse a linked list from position m to n. Do it in one-pass. Note: 1 ≤ m ≤ n ≤ length of list. Example: 1 class Solution { 2 public: 3 ListNode* rev 阅读全文
posted @ 2019-02-24 21:29 TobicYAL 阅读(135) 评论(0) 推荐(0) 编辑
摘要: A message containing letters from A-Z is being encoded to numbers using the following mapping: Given a non-empty string containing only digits, determ 阅读全文
posted @ 2019-02-23 19:16 TobicYAL 阅读(169) 评论(0) 推荐(0) 编辑
摘要: Given a collection of integers that might contain duplicates, nums, return all possible subsets (the power set). Note: The solution set must not conta 阅读全文
posted @ 2019-02-23 17:01 TobicYAL 阅读(117) 评论(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 num 阅读全文
posted @ 2019-02-23 13:50 TobicYAL 阅读(201) 评论(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 representati 阅读全文
posted @ 2019-02-23 10:57 TobicYAL 阅读(200) 评论(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 the 阅读全文
posted @ 2019-02-23 09:37 TobicYAL 阅读(157) 评论(0) 推荐(0) 编辑
摘要: 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组成的最大矩形 题解 1 cl 阅读全文
posted @ 2019-02-23 09:20 TobicYAL 阅读(177) 评论(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 hist 阅读全文
posted @ 2019-02-22 21:32 TobicYAL 阅读(235) 评论(0) 推荐(0) 编辑