随笔分类 -  leetcode

摘要: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 @ 2016-08-17 14:05 冰凌花花~ 阅读(160) 评论(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 @ 2016-08-17 11:18 冰凌花花~ 阅读(617) 评论(0) 推荐(0)
摘要:Given a binary tree, find the maximum path sum. For this problem, a path is defined as any sequence of nodes from some starting node to any node in th 阅读全文
posted @ 2016-08-16 14:56 冰凌花花~ 阅读(142) 评论(0) 推荐(0)
摘要:Given a binary tree, find the maximum path sum from root. The path may end at any node in the tree and contain at least one node in it. 给一棵二叉树,找出从根节点出 阅读全文
posted @ 2016-08-15 17:00 冰凌花花~ 阅读(146) 评论(0) 推荐(0)
摘要:Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA on Wikipedia: “The lowes 阅读全文
posted @ 2016-08-14 23:17 冰凌花花~ 阅读(232) 评论(0) 推荐(0)
摘要:Given a binary search tree (See Definition) and a node in it, find the in-order successor of that node in the BST. If the given node has no in-order s 阅读全文
posted @ 2016-08-14 19:15 冰凌花花~ 阅读(301) 评论(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 @ 2016-08-14 16:22 冰凌花花~ 阅读(153) 评论(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 @ 2016-08-13 18:45 冰凌花花~ 阅读(140) 评论(0) 推荐(0)
摘要:Given a binary tree, return the inorder traversal of its nodes' values. For example:Given binary tree [1,null,2,3], return [1,3,2]. 非递归方法写二叉树的中序遍历 阅读全文
posted @ 2016-08-13 18:13 冰凌花花~ 阅读(177) 评论(0) 推荐(0)
摘要:Given a binary tree, return the preorder traversal of its nodes' values. For example:Given binary tree {1,#,2,3}, return [1,2,3]. 二叉树的前序遍历,非递归的写法考的比较多 阅读全文
posted @ 2016-08-12 19:16 冰凌花花~ 阅读(136) 评论(0) 推荐(0)
摘要:Hi 大家,这道题是leetcode上的find peak element的题,不是lintcode的那道, 这两道题是有区别的,lintcode的题目中说明了:只有某个数左右两侧的元素都小于它,这个数才是峰值, 而leetcode的题,是只要找到个最大值就行,可以是[1,2]里的2这种。 A pe 阅读全文
posted @ 2016-08-11 12:35 冰凌花花~ 阅读(187) 评论(0) 推荐(0)
摘要:Given a sorted array of n integers, find the starting and ending position of a given target value. If the target is not found in the array, return [-1 阅读全文
posted @ 2016-08-10 23:44 冰凌花花~ 阅读(135) 评论(0) 推荐(0)
摘要:You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality c 阅读全文
posted @ 2016-08-09 23:25 冰凌花花~ 阅读(162) 评论(0) 推荐(0)
摘要:Given a big sorted array with positive integers sorted by ascending order. The array is so big so that you can not get the length of the whole array d 阅读全文
posted @ 2016-08-09 22:32 冰凌花花~ 阅读(1037) 评论(0) 推荐(0)
摘要:Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). Find the minimum element. 阅读全文
posted @ 2016-08-07 23:03 冰凌花花~ 阅读(160) 评论(0) 推荐(0)
摘要:For a given sorted array (ascending order) and a target number, find the first index of this number in O(log n) time complexity. If the target number 阅读全文
posted @ 2016-08-07 22:22 冰凌花花~ 阅读(206) 评论(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 sorted f 阅读全文
posted @ 2016-08-07 20:58 冰凌花花~ 阅读(191) 评论(0) 推荐(0)
摘要:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in or 阅读全文
posted @ 2016-08-06 22:26 冰凌花花~ 阅读(126) 评论(0) 推荐(0)
摘要:Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). You are given a target va 阅读全文
posted @ 2016-08-06 18:53 冰凌花花~ 阅读(301) 评论(0) 推荐(0)
摘要:Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. 分析: 给出两个字符串,查询第二个字符串是否在第 阅读全文
posted @ 2016-08-05 18:55 冰凌花花~ 阅读(138) 评论(0) 推荐(0)