随笔分类 -  LeetCode

摘要:题目描述:(链接)Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are... 阅读全文
posted @ 2015-12-21 10:28 skycore 阅读(138) 评论(0) 推荐(0)
摘要:题目描述:(链接)Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each ne... 阅读全文
posted @ 2015-12-20 11:54 skycore 阅读(142) 评论(0) 推荐(0)
摘要:题目描述:(链接)Given a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-leaf path1->2->3... 阅读全文
posted @ 2015-12-20 11:32 skycore 阅读(136) 评论(0) 推荐(0)
摘要:题目描述:(链接)Implementatoito convert a string to an integer.Hint:Carefully consider all possible input cases. If you want a challenge, please do not see b... 阅读全文
posted @ 2015-12-19 15:14 skycore 阅读(133) 评论(0) 推荐(0)
摘要:题目解析:(链接)Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree... 阅读全文
posted @ 2015-12-19 14:41 skycore 阅读(138) 评论(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 n... 阅读全文
posted @ 2015-12-17 22:27 skycore 阅读(160) 评论(0) 推荐(0)
摘要:题目描述:(链接)Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.解题思路: 1 /** 2 * Definition for ... 阅读全文
posted @ 2015-12-17 21:38 skycore 阅读(156) 评论(0) 推荐(0)
摘要:题目描述:(链接)Given an array where elements are sorted in ascending order, convert it to a height balanced BST.解题思路: 1 /** 2 * Definition for a binary tre... 阅读全文
posted @ 2015-12-17 19:32 skycore 阅读(116) 评论(0) 推荐(0)
摘要:题目描述:(链接)Givenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a total of 5 unique B... 阅读全文
posted @ 2015-12-11 22:14 skycore 阅读(155) 评论(0) 推荐(0)
摘要:题目描述:(链接)Given inorder and postorder traversal of a tree, construct the binary tree.解题思路: 1 /** 2 * Definition for a binary tree node. 3 * struct Tr... 阅读全文
posted @ 2015-12-11 10:30 skycore 阅读(142) 评论(0) 推荐(0)
摘要:题目描述:(链接)Given preorder and inorder traversal of a tree, construct the binary tree.解题思路: 1 /** 2 * Definition for a binary tree node. 3 * struct Tre... 阅读全文
posted @ 2015-12-11 10:03 skycore 阅读(166) 评论(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 contai... 阅读全文
posted @ 2015-12-07 10:33 skycore 阅读(174) 评论(0) 推荐(0)
摘要:题目描述:(链接)Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The fl... 阅读全文
posted @ 2015-12-05 13:25 skycore 阅读(175) 评论(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 ... 阅读全文
posted @ 2015-12-05 13:02 skycore 阅读(141) 评论(0) 推荐(0)
摘要:题目描述:(链接)Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: ... 阅读全文
posted @ 2015-12-05 12:48 skycore 阅读(128) 评论(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 giv... 阅读全文
posted @ 2015-12-02 22:09 skycore 阅读(142) 评论(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 ide... 阅读全文
posted @ 2015-12-01 19:36 skycore 阅读(146) 评论(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) ... 阅读全文
posted @ 2015-12-01 19:20 skycore 阅读(168) 评论(0) 推荐(0)
摘要:题目解析:(链接)Given a binary tree, return thezigzag level ordertraversal of its nodes' values. (ie, from left to right, then right to left for the next lev... 阅读全文
posted @ 2015-11-30 14:42 skycore 阅读(136) 评论(0) 推荐(0)
摘要:题目描述:(链接)Given a binary tree, return thebottom-up level ordertraversal of its nodes' values. (ie, from left to right, level by level from leaf to root... 阅读全文
posted @ 2015-11-29 14:24 skycore 阅读(143) 评论(0) 推荐(0)