Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted fr...
分类:
其他好文 时间:
2015-10-04 17:10:18
阅读次数:
132
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy ...
分类:
其他好文 时间:
2015-10-04 17:10:15
阅读次数:
140
Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. For example,Given the following matrix:[ [ 1,...
分类:
其他好文 时间:
2015-10-04 17:10:04
阅读次数:
165
Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's in that surrounded ...
分类:
其他好文 时间:
2015-10-04 17:09:19
阅读次数:
121
Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. For example,Given n = 3,You should return the followin...
分类:
其他好文 时间:
2015-10-04 17:03:59
阅读次数:
106
You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?class Solution ...
分类:
其他好文 时间:
2015-10-04 15:52:14
阅读次数:
154
Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,...
分类:
其他好文 时间:
2015-10-04 15:52:13
阅读次数:
244
题目链接:codeforces 459E题目大意:给出n个点,m条边的有向图,每个边有边权,求一条最长的边权上升的路径的长度。题目分析:
定义dp[i]表示第i条边结尾的情况下的最长路径。
定义g[i]表示点i结尾的情况的最长路径。
对所有的边进行排序,那么前面的边只可能小于等于后面的边。
所以dp[i] = g[e[i].u]+1
然后只需要特殊考虑一下边相等的情况,更新g[i]即可,具体见代码...
分类:
其他好文 时间:
2015-10-03 12:00:07
阅读次数:
191
意甲冠军:它需要一个特殊的图,以找到最大匹配。该图的特征是:无向图,度的每个节点3。这是一个双边连接组件(the graph is 2-edge-connected (that is, at least 2 edges need to be removed in order to make the ...
分类:
其他好文 时间:
2015-10-02 12:35:51
阅读次数:
266
主要是看了这篇文章http://www.geeksforgeeks.org/union-find/总结下目前理解的Union-Find用在disjoint-set data structure上,disjoint-set keeps track of a set of elements partit...
分类:
其他好文 时间:
2015-09-29 06:38:18
阅读次数:
178