摘要: Givennnon-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histog... 阅读全文
posted @ 2014-06-26 23:57 OpenSoucre 阅读(197) 评论(0) 推荐(0) 编辑
摘要: Given amxnmatrix, if an element is 0, set its entire row and column to 0. Do it in place.click to show follow up.Follow up:Did you use extra space?A s... 阅读全文
posted @ 2014-06-26 22:55 OpenSoucre 阅读(183) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest le... 阅读全文
posted @ 2014-06-26 22:16 OpenSoucre 阅读(147) 评论(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-06-26 21:43 OpenSoucre 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 【转载】【啊哈!算法】系列8:巧妙的邻接表(数组实现) http://www.cnblogs.com/ahalei/p/3651334.html 之前我们介绍过图的邻接矩阵存储法,它的空间和时间复杂度都是N2,现在我来介绍另外一种存储图的方法:邻接表,这样空间和时间复杂度就都是M。对于稀疏图来说... 阅读全文
posted @ 2014-06-26 17:56 OpenSoucre 阅读(220) 评论(0) 推荐(0) 编辑
摘要: 第一节 镖局运镖-图的最小生成树所谓最小生成树,就是在一个具有N个顶点的带权连通图G中,如果存在某个子图G',其包含了图G中的所有顶点和一部分边,且不形成回路,并且子图G'的各边权值之和最小,则称G'为图G的最小生成树。最小生成树的三个性质最小生成树不能有回路最小生成树可能是一个,也可能有多个最小... 阅读全文
posted @ 2014-06-26 16:11 OpenSoucre 阅读(549) 评论(0) 推荐(0) 编辑
摘要: 第3节 堆排序把n个元素建立一个堆,首先将这n个结点以自顶向下、从左到右的方式从1到n编码,这样可以把n个结点转换成一颗完全二叉树紧接着从最后一个非叶子结点(结点编号为n/2)开始到根节点(结点编号为1),逐个扫描所有结点,根据需要将当前结点向下调整,直到以当前结点为根结点的子树符合堆的特性。#in... 阅读全文
posted @ 2014-06-26 12:53 OpenSoucre 阅读(276) 评论(0) 推荐(0) 编辑
摘要: Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sorted from l... 阅读全文
posted @ 2014-06-26 00:23 OpenSoucre 阅读(187) 评论(0) 推荐(0) 编辑