摘要: Write an algorithm such that if an element in an MxN matrix is 0, its entire row andcolumn is set to 0写一个算法使得把一个M*N的矩阵中0元素所在位置的行列设置为零At first glance, this problem seems easy: just iterate through the matrix and every time wesee a 0, set that row and column to 0 There’s one problem with that soluti.. 阅读全文
posted @ 2012-07-14 21:02 JWMNEU 阅读(225) 评论(0) 推荐(0) 编辑
摘要: Given an image represented by an NxN matrix, where each pixel in the imageis 4bytes, write a method to rotate the image by 90 degrees Can you do this in place?描述:给定一个N*N的图像,每个位置的像素是4byte,写一个方法用来在原来的空间内旋转图像90度。思路:我们可以按层来旋转。void matrixRotation(int [][]a,int n) { for(int layer=0;layer<n;layer++) { . 阅读全文
posted @ 2012-07-14 19:57 JWMNEU 阅读(325) 评论(0) 推荐(0) 编辑