摘要: Given an array where elements are sorted in ascending order, convert it to a height balanced BST.首先我是要AVL树的创建过程进行操作,不过提交之后出现超时,但还是让我将AVL树的创建过程实现了一遍,记录... 阅读全文
posted @ 2014-11-21 22:25 Jessica程序猿 阅读(229) 评论(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 depth... 阅读全文
posted @ 2014-11-21 20:25 Jessica程序猿 阅读(156) 评论(0) 推荐(0) 编辑
摘要: The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integernrepresenting the total number... 阅读全文
posted @ 2014-11-21 19:39 Jessica程序猿 阅读(160) 评论(0) 推荐(0) 编辑
摘要: Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete a... 阅读全文
posted @ 2014-11-21 18:47 Jessica程序猿 阅读(141) 评论(0) 推荐(0) 编辑
摘要: Dynamic ProgrammingSay you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to complete at most ... 阅读全文
posted @ 2014-11-21 17:39 Jessica程序猿 阅读(124) 评论(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 le... 阅读全文
posted @ 2014-11-21 17:05 Jessica程序猿 阅读(163) 评论(0) 推荐(0) 编辑
摘要: Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possibl... 阅读全文
posted @ 2014-11-21 15:33 Jessica程序猿 阅读(166) 评论(0) 推荐(0) 编辑
摘要: Given a collection of numbers, return all possible permutations.For example,[1,2,3]have the following permutations:[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,... 阅读全文
posted @ 2014-11-21 13:41 Jessica程序猿 阅读(223) 评论(0) 推荐(0) 编辑
摘要: Evaluate the value of an arithmetic expression inReverse Polish Notation.Valid operators are+,-,*,/. Each operand may be an integer or another express... 阅读全文
posted @ 2014-11-21 10:45 Jessica程序猿 阅读(216) 评论(0) 推荐(0) 编辑
摘要: You are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?C++实现代码:#include#in... 阅读全文
posted @ 2014-11-21 10:05 Jessica程序猿 阅读(205) 评论(0) 推荐(0) 编辑
摘要: Implement pow(x,n).C++实现代码:#includeusing namespace std;class Solution{public: double pow(double x, int n) { if(x==0&&n==0) ret... 阅读全文
posted @ 2014-11-21 09:16 Jessica程序猿 阅读(182) 评论(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 @ 2014-11-21 08:36 Jessica程序猿 阅读(177) 评论(0) 推荐(0) 编辑
摘要: Dynamic ProgrammingFind the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the arra... 阅读全文
posted @ 2014-11-21 08:23 Jessica程序猿 阅读(160) 评论(0) 推荐(0) 编辑