need to use scratch to find the pattern

class Solution {
public void rotate(int[][] matrix) {
int n=matrix.length;
for (int i=0; i<n/2; i++)
for (int j=i; j<n-i-1; j++) {
int tmp=matrix[i][j];
matrix[i][j]=matrix[n-j-1][i];
matrix[n-j-1][i]=matrix[n-i-1][n-j-1];
matrix[n-i-1][n-j-1]=matrix[j][n-i-1];
matrix[j][n-i-1]=tmp;
}
return;}
}

48. Rotate Image via java的更多相关文章

  1. [Leetcode][Python]48: Rotate Image

    # -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 48: Rotate Imagehttps://leetcode.com/pr ...

  2. [array] leetcode - 48. Rotate Image - Medium

    leetcode - 48. Rotate Image - Medium descrition You are given an n x n 2D matrix representing an ima ...

  3. 刷题48. Rotate Image

    一.题目说明 题目是48. Rotate Image,简而言之就是矩阵顺时针旋转90度.不允许使用额外的矩阵. 经过观察(写一个矩阵,多看几遍就知道了),旋转90度后: 第1行变为len-1列(最后一 ...

  4. 48. Rotate Image - LeetCode

    Question 48. Rotate Image Solution 把这个二维数组(矩阵)看成一个一个环,循环每个环,循环每条边,每个边上的点进行旋转 public void rotate(int[ ...

  5. 48. Rotate Image

    题目: You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwis ...

  6. LeetCode OJ 48. Rotate Image

    You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). ...

  7. LeetCode 48. Rotate Image(旋转图像)

    You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). ...

  8. LeetCode算法题-Rotate String(Java实现)

    这是悦乐书的第317次更新,第338篇原创 在开始今天的算法题前,说几句,今天是世界读书日,推荐两本书给大家,<终身成长>和<禅与摩托车维修艺术>,值得好好阅读和反复阅读. 0 ...

  9. LeetCode算法题-Rotate Array(Java实现)

    这是悦乐书的第184次更新,第186篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第43题(顺位题号是189).给定一个数组,将数组向右旋转k步,其中k为非负数.例如: ...

  10. [LeetCode] 48. Rotate Image 旋转图像

    You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). ...

随机推荐

  1. OpenSSL测试-SM3

    OpenSSL测试-SM3 1.使用OpenSSL的命令计算你的8位学号的摘要值(SM3),提交截图. 运行结果 2.使用OpenSSL编程对计算"你的8位学号"SM3摘要值,提交 ...

  2. Cendos中启动docker失败的问题

    注:在 Windows中使用Linux虚拟机中使用Cendos 刚开始安装Docker时没有任何错误, 但是在后续的docker启动过程中, 出现以下问题: 按提示使用 systemctl statu ...

  3. GIS空间分析和建模复习重点3

    22.网络分析的相关算法 (1)Dijkstra算法(求解给定点与其他所有点之间的最短路径即单源点最短路径问题) (2)Floyd算法(直接计算任意两节点之间最短路) (3)最小生成树即Prim算法. ...

  4. Ubuntu20.04安装PEA软件

    PEA软件可用于实时精密卫星钟差估计,精密卫星定轨,精密单点定位,电离层建模以及DCB估计等. Ginan开发人员推荐使用Ubuntu18.04或Ubuntu20.04搭建,本文使用Ubuntu20. ...

  5. pytest-2 之前后置及 conftest.py+fixture+yield实现用例前后置

    pytest测试用例及类级别的前置,可以和unittest一样进行定义,也可以把该前置方法或类定义到conftest.py里,而在需要前置的方法的参数里加上该前置名作为参数: pytest有两种方式来 ...

  6. Angular中播放RTSP

    要使用这个库需要先安装 我使用了npm来安装 https://www.npmjs.com/package/webrtc-streamer 需要启动webrtc-streamer后端,这里有下载地址 h ...

  7. thunar文件管理器修改默认的关联的终端

    有时候在文件管理器的文件夹中打开终端操作很方便.目前好用的文件管理器基本和虚拟中终端基本上是各个桌面环境的配套产品. 比如xfce环境的thunar文件管理器如果想搭配lxde环境的lxtermina ...

  8. 【运维】解决composer update出现的Discard changes [y,n,v,d,s,?]的问题

    在PHP项目中,composer是一个使用非常普遍的包管理工具,在本地开发的时候出现了这个问题一搬来说问题不大,可以人为进行输入交互,但是如果是自动化发布中出现,就会等待输入导致卡住,是一个需要解决的 ...

  9. HybridCLR热更新方案

    Hybrid指的是混合开发,CLR指的是公共语言运行库(Common Language Runtime)->托管代码执行核心中的引擎.前身叫做huatuo git示例项目地址为https://g ...

  10. jmeter取样器之KafkaProducerSampler(往kafka插入数据)

    项目背景 性能测试场景中有一个业务场景的数据抽取策略是直接使用kafka队列,该场景需要准备的测试数据是kafka队列里的数据,故需要实现插入数据到kafka队列,且需要实现控制每分钟插入多少条数据. ...