
LeetCode解题
风啸葛溪
这个作者很懒,什么都没留下…
展开
-
[LeetCode]Search Insert Position
题目:Search Insert PositionGiven a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointe原创 2014-04-13 22:32:09 · 548 阅读 · 0 评论 -
[LeetCode]Single Number II
题目:Single Number II 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原创 2014-04-24 21:25:43 · 689 阅读 · 0 评论 -
[LeetCode]Climbing Stairs
题目:Single Number II Given an array of integers, every element appears three times except for one. Find that single one.Note:Your algorithm should have a linear runt原创 2014-04-24 21:48:10 · 660 阅读 · 0 评论 -
[LeetCode]Maximum Subarray
题目:Climbing StairsYou are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?原创 2014-04-25 22:39:39 · 552 阅读 · 0 评论 -
[LeetCode]Merge Two Sorted Lists
题目:Merge Two Sorted ListsGiven a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.来源:http://oj.leetco原创 2014-05-11 20:56:22 · 578 阅读 · 0 评论 -
[LeetCode]Best Time to Buy and Sell Stock
题目:Remove Duplicates from Sorted Array IISay you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to co原创 2014-08-03 21:45:20 · 702 阅读 · 0 评论 -
[LeetCode]Pascal's Triangle II
题目:Pascal's TriangleGiven numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,原创 2014-07-19 20:43:35 · 532 阅读 · 0 评论 -
[LeetCode]Balanced Binary Tree
题目:Balanced Binary Tree Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary原创 2014-08-10 20:14:47 · 730 阅读 · 0 评论 -
[LeetCode]Remove Duplicates from Sorted Array
题目:Remove Duplicates from Sorted ArrayGiven two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space原创 2014-07-27 21:28:40 · 537 阅读 · 0 评论 -
[LeetCode]Merge Sorted Array
题目:Pascal's TriangleGiven two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space (size that is greater or原创 2014-07-20 17:10:19 · 629 阅读 · 0 评论 -
[Leetcode]Pascal's Triangle
题目:Merge Two Sorted ListsGiven numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1],原创 2014-07-19 20:33:06 · 559 阅读 · 0 评论 -
[LeetCode]Remove Duplicates from Sorted Array II
题目:Remove Duplicates from Sorted Array IIFollow up for "Remove Duplicates":What if duplicates are allowed at most twice?For example,Given sorted array A = [原创 2014-08-03 20:33:30 · 689 阅读 · 0 评论 -
[LeetCode]Convert Sorted Array to Binary Search Tree
题目:Balanced Binary Tree 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 depth of原创 2014-08-17 20:06:18 · 577 阅读 · 0 评论 -
[LeetCode]Populating Next Right Pointers in Each Node
题目:Linked List CycleGiven a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next point原创 2014-04-08 21:15:51 · 592 阅读 · 0 评论 -
[LeetCode]Binary Tree Postorder Traversal
题目:Binary Tree Postorder Traversal Given a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2原创 2014-03-26 20:26:09 · 563 阅读 · 0 评论 -
[LeetCode]Integer to Roman
题目:Maximum Subarray Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [−2,1,−3,4,−1,2,1,−5,4],原创 2014-04-29 22:33:05 · 837 阅读 · 0 评论 -
[LeetCode]Maximum Depth of Binary Tree
题目:Maximum Depth of Binary Tree 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 leaf node.原创 2014-03-17 20:55:12 · 632 阅读 · 0 评论 -
[LeetCode]Reverse Integer
题目:Reverse Integer Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321来源:http://oj.leetcode.com/problems/reverse-integer/思路:截位,一位一位的来;原创 2014-03-19 19:24:48 · 552 阅读 · 0 评论 -
[LeetCode]Single Number
题目:Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have alinear runtime complexity. Could you implement it without using原创 2014-03-16 21:04:26 · 554 阅读 · 0 评论 -
[LeetCode]Unique Binary Search Trees
题目:Unique Binary Search Trees Given n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique BST's.原创 2014-03-19 19:30:54 · 602 阅读 · 0 评论 -
[LeetCode]Best Time to Buy and Sell Stock II
题目:Best Time to Buy and Sell Stock II Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may c原创 2014-03-21 19:52:36 · 839 阅读 · 0 评论 -
[LeetCode]Linked List Cycle
题目:Linked List Cycle Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?来源:http://oj.leetcode.com/problems/linked-list-原创 2014-04-02 18:51:32 · 579 阅读 · 0 评论 -
[LeetCode]Same Tree
题目:Same TreeGiven two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same valu原创 2014-03-17 21:44:05 · 604 阅读 · 0 评论 -
[LeetCode]Roman to Integer
题目:Integer to Roman Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.原创 2014-05-07 19:57:11 · 713 阅读 · 0 评论 -
[LeetCode]Binary Tree Inorder Traversal
题目:Binary Tree Inorder Traversal Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2原创 2014-03-26 20:20:16 · 503 阅读 · 0 评论 -
[LeetCode]Remove Element
题目:Remove Element Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.来源:http://oj.leetcode.com/原创 2014-05-07 20:13:57 · 509 阅读 · 0 评论 -
[LeetCode]Binary Tree Preorder Traversal
题目:Binary Tree Preorder TraversalGiven a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3re原创 2014-03-24 20:25:39 · 532 阅读 · 0 评论 -
[LeedCode]Swap Nodes in Pairs
题目:Convert Sorted Array to Binary Search Tree Given an array where elements are sorted in ascending order, convert it to a height balanced BST.来源:http原创 2014-09-14 21:02:47 · 657 阅读 · 0 评论