随笔分类 -  leetcode

上一页 1 ··· 7 8 9 10 11 12 13 14 15 下一页
摘要: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 fol 阅读全文
posted @ 2017-06-18 22:47 鸭子船长 阅读(177) 评论(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 @ 2017-06-18 22:35 鸭子船长 阅读(448) 评论(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 @ 2017-06-18 22:21 鸭子船长 阅读(253) 评论(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. 阅读全文
posted @ 2017-06-18 22:17 鸭子船长 阅读(184) 评论(0) 推荐(0)
摘要:题意:根据二叉树的中序遍历和后序遍历恢复二叉树。 解题思路:看到树首先想到要用递归来解题。以这道题为例:如果一颗二叉树为{1,2,3,4,5,6,7},则中序遍历为{4,2,5,1,6,3,7},后序遍历为{4,5,2,6,7,3,1},我们可以反推回去。由于后序遍历的最后一个节点就是树的根。也就是 阅读全文
posted @ 2017-06-17 23:25 鸭子船长 阅读(215) 评论(0) 推荐(0)
摘要:I 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{ 阅读全文
posted @ 2017-06-15 16:15 鸭子船长 阅读(260) 评论(0) 推荐(0)
摘要:Convert Sorted List to Binary Search Tree Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST 阅读全文
posted @ 2017-06-15 15:40 鸭子船长 阅读(165) 评论(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 dept 阅读全文
posted @ 2017-06-14 15:18 鸭子船长 阅读(236) 评论(0) 推荐(0)
摘要:I、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 sum. 阅读全文
posted @ 2017-06-14 12:33 鸭子船长 阅读(132) 评论(0) 推荐(0)
摘要:Given a string S and a string T, count the number of distinct subsequences ofT inS. A subsequence of a string is a new string which is formed from the 阅读全文
posted @ 2017-06-14 00:00 鸭子船长 阅读(3018) 评论(0) 推荐(0)
摘要:1、 Given a binary tree Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to N 阅读全文
posted @ 2017-06-13 18:16 鸭子船长 阅读(163) 评论(0) 推荐(0)
摘要:1、Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Return [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] 阅读全文
posted @ 2017-06-13 16:11 鸭子船长 阅读(290) 评论(0) 推荐(0)
摘要:Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example, given the fo 阅读全文
posted @ 2017-06-13 16:03 鸭子船长 阅读(196) 评论(0) 推荐(0)
摘要:1、 Say you have an array for which the i th element is the price of a given stock on day i . If you were only permitted to complete at most one transa 阅读全文
posted @ 2017-06-13 15:42 鸭子船长 阅读(323) 评论(0) 推荐(0)
摘要:Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree. For example:Given the below binary tree, Return 6. 阅读全文
posted @ 2017-06-13 14:59 鸭子船长 阅读(934) 评论(0) 推荐(0)
摘要:Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example,"A man, a plan, a canal: Pan 阅读全文
posted @ 2017-06-13 12:40 鸭子船长 阅读(351) 评论(0) 推荐(0)
摘要:Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) from start to end, such that: For example, Given:start 阅读全文
posted @ 2017-06-13 12:21 鸭子船长 阅读(467) 评论(0) 推荐(0)
摘要:Word Ladder Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that: For e 阅读全文
posted @ 2017-06-13 00:05 鸭子船长 阅读(467) 评论(0) 推荐(0)
摘要:Given an unsorted array of integers, find the length of the longest consecutive elements sequence. For example,Given[100, 4, 200, 1, 3, 2],The longest 阅读全文
posted @ 2017-06-12 23:06 鸭子船长 阅读(1729) 评论(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->3which re 阅读全文
posted @ 2017-06-12 22:36 鸭子船长 阅读(244) 评论(0) 推荐(0)

上一页 1 ··· 7 8 9 10 11 12 13 14 15 下一页