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. nginx 结合tomcat 双机热备

    相信很多人都听过nginx,这个小巧的东西慢慢地在吞食apache和IIS的份额.那究竟它有什么作用呢?可能很多人未必了解. 说到反向代理,可能很多人都听说,但具体什么是反向代理,很多人估计就不清楚了 ...

  2. nextLine和hasNextLine的区别

    == 重点:如果要判断一个文件这一行是否还有可读数据不能通过nextLine != null 来判断,要用hasNextLine是否为真来判断. == 1.nextLine: 公共字符串nextLin ...

  3. shell之flock

    1.flock 最大的用途就是实现对 crontab 任务的串行化:为了防止crontab 任务出现多实例的情况,导致系统内存被耗尽. 在 crontab 任务中,有可能出现某个任务的执行时间超过了 ...

  4. 常见的Native Crash类型,bug解决记录

    APP调用Native的jar包接口出现闪退,仅仅settings应用,其他应用调用该包接口正常使用. 猜测1. jar包为64为,settings程序为32位,版本兼容性问题.(经验证,原因确实如此 ...

  5. 阿里云centos7安装图形界面gnome

    这应该是很无聊很蛇精的操作吧. 首先命令行远程登陆阿里云,然后root身份更新系统,安装gnome这些操作(菜如我以前都没有操作过),参照网上虚拟机的教程. # yum update -y # yum ...

  6. YOLOV4网络

    Yolov4网络代码 from collections import OrderedDict import torch import torch.nn as nn from Darknet_53 im ...

  7. 提交docker镜像到远程仓库

    生成镜像 Docker build 镜像 编辑Dockerfile文件 新建Dockerfile文件,将如下构建脚本复制进去 # Build for ansible envirament FROM c ...

  8. 如何查看nvidia官网发布的tensorrt镜像中都包含哪些包,trt版本是多少,cuda版本是多少?如何查看nvidia官网发布的triton镜像中都包含哪些包?

    在这里查看trt镜像中包含哪些内容:https://docs.nvidia.com/deeplearning/tensorrt/container-release-notes/rel_21-07.ht ...

  9. JVM系列(四):GC策略

    一.概念 GC,Garbage Collection垃圾回收,主要针对JVM中的堆和方法区,而JVM栈.本地方法栈,程序计数器都是线程私有的,跟随线程生命周期. 二.对象存活判断 1. 引用计数:每个 ...

  10. dart extends 覆盖规则

    1,不覆写super的变量,child会自动继承super的变量.即使是在child里给super赋值,child里也是可以访问到的,可能是因为引用的关系. 2,只要覆写了super的变量,只给sup ...