You are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?思路:首先左右翻转,然后按照左下,右上...
分类:
其他好文 时间:
2014-09-03 19:50:47
阅读次数:
241
思路: 找到第一个 0 元素,记下其行和列。然后对其他 0 元素,分别将其投影在记下的行和列上(做标记)。遍历之后,对于所有行中的标记,将其所在列都置为 0; 对于所有列中标记,将其所在行都置为 0. (最后置标记的行和列为 0. 可含在上述步骤) 时间: O(n2), 空间 : O(1)
分类:
其他好文 时间:
2014-09-03 19:45:37
阅读次数:
212
思路: 从右上方开始,若小于 target, 则往下走;若大于 target, 对改行二分查找;若等 target, 返回 true.
思路: 斐波那契。此处用动归。 还可以使用矩阵二分乘。(剑指offer: 题9)
分类:
其他好文 时间:
2014-09-03 19:42:47
阅读次数:
249
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2316题目意思:有 N 个 点,M 条 边。需要构造一个N * M 大小的矩阵A。对于 (i, j) 这个坐标点它表示,对编号为 i 这个点编号为 j 的 点与它相连...
分类:
其他好文 时间:
2014-09-02 19:26:25
阅读次数:
182
You are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-placen*n矩阵顺时针旋转90度,规律 a[i...
分类:
其他好文 时间:
2014-09-02 17:14:04
阅读次数:
180
poj 3070Fibonaccihttp://poj.org/problem?id=3070模板题,矩阵都给你写好了。 1 #include 2 #include 3 #define mt(a,b) memset(a,b,sizeof(a)) 4 class Matrix { ///矩阵 5 .....
分类:
其他好文 时间:
2014-09-01 22:20:53
阅读次数:
335
题意:求两个n x n的矩阵相乘后模3的结果,n
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4920
——>>呀呀。。
1、3层计算的for进行缓存优化,根据CPU的L1级缓存的实现原理,减少缓存的变更。如果每次都计算完一个单元格的结果再计算下一个单元格的结果,那么被乘矩阵的访问就会频繁地更新缓存,使效率很低。。
2、输入开挂,G++提...
分类:
其他好文 时间:
2014-09-01 21:15:36
阅读次数:
252
Question:Given an M x N matrix in which each row and each column is sorted in ascending order, write a method to find an element. 1 package POJ; 2 3 ....
分类:
其他好文 时间:
2014-09-01 02:44:02
阅读次数:
209
Spiral Matrix
Total Accepted: 12721 Total
Submissions: 62094My Submissions
Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.
For ex...
分类:
其他好文 时间:
2014-08-31 17:19:01
阅读次数:
210
Spiral Matrix II
Total Accepted: 12773 Total
Submissions: 41526My Submissions
Given an integer n, generate a square matrix filled with elements from 1 to n2 in
spiral order.
For exampl...
分类:
其他好文 时间:
2014-08-31 17:17:11
阅读次数:
128