摘要: There are a total ofncourses you have to take, labeled from0ton - 1.Some courses may have prerequisites, for example to take course 0 you have to firs... 阅读全文
posted @ 2016-01-15 11:46 zhanghill 阅读(850) 评论(0) 推荐(0)
摘要: Given an array ofnpositive integers and a positive integers, find the minimal length of a subarray of which the sum ≥s. If there isn't one, return 0 i... 阅读全文
posted @ 2016-01-15 11:29 zhanghill 阅读(429) 评论(0) 推荐(0)
摘要: There are a total ofncourses you have to take, labeled from0ton - 1.Some courses may have prerequisites, for example to take course 0 you have to firs... 阅读全文
posted @ 2016-01-14 17:04 zhanghill 阅读(420) 评论(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 @ 2016-01-11 16:47 zhanghill 阅读(113) 评论(0) 推荐(0)
摘要: Say 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 one transaction (ie... 阅读全文
posted @ 2016-01-11 16:35 zhanghill 阅读(266) 评论(0) 推荐(0)
摘要: Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution stil... 阅读全文
posted @ 2016-01-11 14:14 zhanghill 阅读(136) 评论(0) 推荐(0)
摘要: Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointe... 阅读全文
posted @ 2016-01-11 14:08 zhanghill 阅读(149) 评论(0) 推荐(0)
摘要: 问题: Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.思路:先遍历一遍链表,将值存入一个vector中,再讲vector中有序... 阅读全文
posted @ 2016-01-06 16:13 zhanghill 阅读(275) 评论(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 @ 2015-12-23 16:53 zhanghill 阅读(122) 评论(0) 推荐(0)
摘要: Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possibl... 阅读全文
posted @ 2015-12-22 16:19 zhanghill 阅读(1456) 评论(0) 推荐(0)