
leetcode
文章平均质量分 73
小菜鸟的leetcode
这个作者很懒,什么都没留下…
展开
-
Leetcode Binary Tree Right Side View
ProblemGiven a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.For example:Given the following binary原创 2016-02-21 09:32:16 · 295 阅读 · 0 评论 -
303. Range Sum Query - Immutable [Leetcode]
ProblemGiven an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.Example:Given nums = [-2, 0, 3, -5, 2, -1]sumRange(0, 2) -> 1sumRange(2原创 2016-01-28 13:35:44 · 341 阅读 · 0 评论 -
299. Bulls and Cows
ProblemYou are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you pro原创 2016-01-24 14:34:32 · 389 阅读 · 0 评论 -
298. Binary Tree Longest Consecutive Sequence
ProblemGiven a binary tree, find the length of the longest consecutive sequence path.The path refers to any sequence of nodes from some starting node to any node in the tree along the pa原创 2016-01-24 13:52:12 · 325 阅读 · 0 评论 -
296. Best Meeting Point
ProblemA group of two or more people wants to meet and minimize the total travel distance. You are given a 2D grid of values 0 or 1, where each 1 marks the home of someone in the group. The dist原创 2016-01-20 12:42:36 · 914 阅读 · 0 评论 -
295. Find Median from Data Stream
ProblemMedian is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle value.Examples: [2,3,4]原创 2016-01-20 11:25:04 · 351 阅读 · 0 评论 -
H-Index II
Problem Follow up for H-Index: What if the citations array is sorted in ascending order? Could you optimize your algorithm?Solution 二分查找class Solution {public: int hIndex原创 2016-01-19 13:32:33 · 342 阅读 · 0 评论 -
leetcode Paint Fence
ProblemThere is a fence with n posts, each post can be painted with one of the k colors.You have to paint all the posts such that no more than two adjacent fence posts have the same color.原创 2016-01-19 12:05:23 · 373 阅读 · 0 评论 -
leetcode Ugly Number II
ProblemWrite a program to find the n-th ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence原创 2016-01-10 12:46:42 · 321 阅读 · 0 评论 -
leetcode Move Zeroes
testtest原创 2016-01-05 13:11:42 · 312 阅读 · 0 评论 -
[leetcode]Inorder Successor in BST
ProblemGiven a binary search tree and a node in it, find the in-order successor of that node in the BST.Note: If the given node has no in-order successor in the tree, return null.S原创 2015-12-31 14:29:27 · 509 阅读 · 0 评论