先左右对称反转,再沿右对角线对折,面试记住就行了 代码: 1 class Solution { 2 public: 3 void rotate(vector<vector<int>>& matrix) { 4 int len = matrix.size(); 5 //左右翻 6 for(int i= ...
分类:
其他好文 时间:
2020-02-20 10:13:45
阅读次数:
76
public class Solution { /** * @param costs: n x 3 cost matrix * @return: An integer, the minimum cost to paint all houses */ public int minCost(int[][ ...
分类:
其他好文 时间:
2020-02-19 21:05:47
阅读次数:
63
常用测量矩阵及matlab实现 随机高斯测量矩阵 function [ Phi ] = GaussMtx( M,N ) %GaussMtx Summary of this function goes here %Generate Bernoulli matrix %M -- RowNumber %N ...
分类:
其他好文 时间:
2020-02-19 15:24:44
阅读次数:
96
给定M×N矩阵,每一行、每一列都按升序排列,请编写代码找出某元素。 示例: 现有矩阵 matrix 如下: [ [1, 4, 7, 11, 15], [2, 5, 8, 12, 19], [3, 6, 9, 16, 22], [10, 13, 14, 17, 24], [18, 21, 23, 26 ...
分类:
编程语言 时间:
2020-02-18 16:33:23
阅读次数:
90
一、定义动画过程中形成的状态用transformtransform 分为2D 和 3D,主要包含以下几种变换:旋转rotate、扭曲skew、缩放scale和移动 translate以及矩阵变形matrix,语法如下:1transform: rotate | scale | skew | trans... ...
分类:
其他好文 时间:
2020-02-18 13:24:01
阅读次数:
68
Given a m * n matrix grid which is sorted in non-increasing order both row-wise and column-wise. Return the number of negative numbers in grid. Exampl ...
分类:
其他好文 时间:
2020-02-18 13:04:04
阅读次数:
75
给定 $n$ 个点 $k$ 棵树的森林,第 $i$ 棵树的大小为 $s_i$,要求加入 $k 1$ 条边,使之连通,求方案数。 设第 $i$ 棵树的度数为 $d_i$,则对于给定 $d_1,d_2,\cdots,d_k$,根据 prufer 序列 ,进行可重集排列 $$ \begin{pmatrix ...
分类:
其他好文 时间:
2020-02-15 13:32:00
阅读次数:
84
1 """ 2 Given a matrix consists of 0 and 1, find the distance of the nearest 0 for each cell. 3 The distance between two adjacent cells is 1. 4 Exampl ...
分类:
其他好文 时间:
2020-02-15 11:50:37
阅读次数:
74
面试题03. 数组中重复的数字 在一个长度为 n 的数组 nums 里的所有数字都在 0~n-1 的范围内。数组中某些数字是重复的,但不知道有几个数字重复了,也不知道每个数字重复了几次。请找出数组中任意一个重复的数字。 思路:1. 利用字典,时间复杂度O(n),空间复杂度O(n) class Sol ...
分类:
其他好文 时间:
2020-02-14 22:52:28
阅读次数:
100
a<-matrix(11:30,ncol = 2) a colnames(a)<-LETTERS[1:2] a plot(a,col="red") rnorm(10,mean = 20 , sd = 3) round(rnorm(10,mean = 20 , sd = 3),1) LETTERS[1 ...
分类:
其他好文 时间:
2020-02-14 22:35:30
阅读次数:
68