摘要: There are two ways to conduct BFS on tree.Solution 1 -- Given levelUse recursion to find given level, and print./*Function to print level order traver... 阅读全文
posted @ 2015-09-24 04:18 树獭君 阅读(294) 评论(0) 推荐(0) 编辑
摘要: QuestionFind thekth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.Fo... 阅读全文
posted @ 2015-09-22 07:24 树獭君 阅读(692) 评论(0) 推荐(0) 编辑
摘要: QuestionMergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity.Solution 1 -- Merge SortWe can follow the meth... 阅读全文
posted @ 2015-09-22 04:53 树獭君 阅读(135) 评论(0) 推荐(0) 编辑
摘要: QuestionThere are two sorted arraysnums1andnums2of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexit... 阅读全文
posted @ 2015-09-22 03:03 树獭君 阅读(192) 评论(0) 推荐(0) 编辑
摘要: QuestionGiven a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and return its area.For example, given the follow... 阅读全文
posted @ 2015-09-21 08:40 树獭君 阅读(156) 评论(0) 推荐(0) 编辑
摘要: QuestionSay 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 co... 阅读全文
posted @ 2015-09-21 07:23 树獭君 阅读(138) 评论(0) 推荐(0) 编辑
摘要: QuestionSay 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 co... 阅读全文
posted @ 2015-09-21 05:39 树獭君 阅读(164) 评论(0) 推荐(0) 编辑
摘要: QuestionSay 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 transac... 阅读全文
posted @ 2015-09-21 03:47 树獭君 阅读(192) 评论(0) 推荐(0) 编辑
摘要: QuestionGiven a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given... 阅读全文
posted @ 2015-09-21 03:30 树獭君 阅读(200) 评论(0) 推荐(0) 编辑
摘要: QuestionGivenn, generate all structurally uniqueBST's(binary search trees) that store values 1...n.For example,Givenn= 3, your program should return a... 阅读全文
posted @ 2015-09-21 02:36 树獭君 阅读(160) 评论(0) 推荐(0) 编辑