【题目】
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 from left to right.
The first integer of each row is greater than the last integer of the previous ...
分类:
其他好文 时间:
2014-06-05 08:28:43
阅读次数:
321
【题目】
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.
【题意】
给定一个mXn的矩阵,如果其中的元素为0,则对应的行和列都用0填充。
不能申请额外的空间。
【思路】
第一行和第一列空出来标记需要置0的列和行
第一遍扫描:
扫描第一行,判断第一行是否需要清零
...
分类:
其他好文 时间:
2014-06-05 08:07:11
阅读次数:
229
题目来源:POJ 2155 Matrix
题意:开始矩阵都是0 2种操作 把某个子矩阵翻转 0变1 1变0 查询x y 是0还是1
思路:树状数组 记录翻转次数就行 奇数次是1 偶数次是0
这题是区间更新 点查询 向上求和 向下更新 而且是二维的
#include
#include
using namespace std;
const int maxn = 1300;
i...
分类:
其他好文 时间:
2014-06-05 01:59:00
阅读次数:
287
You are given annxn2D matrix representing an
image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this
in-place?classSolution{publi...
分类:
其他好文 时间:
2014-06-04 20:25:09
阅读次数:
227
Given a matrix ofmxnelements (mrows,ncolumns),
return all elements of the matrix in spiral order.For example,Given the
following matrix:[ [ 1, 2, 3 ]....
分类:
其他好文 时间:
2014-06-04 20:06:52
阅读次数:
256
Given an integern, generate a square matrix
filled with elements from 1 ton2in spiral order.For example,Givenn=3,You should
return the following matri...
分类:
其他好文 时间:
2014-06-04 19:28:23
阅读次数:
220
BNUOJ 34981 A Matrix
题目地址:BNUOJ 34981
题意:
给你一个把一个排列放到矩阵里面的算法和矩阵,要你从矩阵写出排列。
如果答案有多个,输出翻转后字典序最大的那个。
分析:
想了半天只能想到链表版的,而且很可能TLE,看了帆神的题解后豁然开朗..Orz..
代码:
/*
* Author: illuz
*...
分类:
其他好文 时间:
2014-06-03 02:15:20
阅读次数:
187
【题目】
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.
【题意】
给定一个由0和1填充的二维矩阵,找一个全是1的最大矩形
【思路】
扫描二维矩阵,凡是扫到值为1的块时候,以当前块为矩形的左上角区块拓展,找最大矩阵。
先找出以每个“1”区块为左上角区块的最大矩形,然后求出最大全局的最大矩...
分类:
其他好文 时间:
2014-06-02 23:08:07
阅读次数:
289
Fast Matrix OperationsThere is a matrix
containing at most 106elements divided into r rows and c columns. Each element
has a location (x,y) where 10)2...
分类:
其他好文 时间:
2014-05-30 03:31:23
阅读次数:
516
Rotate ImageYou 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?最简...
分类:
其他好文 时间:
2014-05-29 23:02:38
阅读次数:
254