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. [WSL-1-Ubuntu]使用oh-my-zsh美化你的WSL(附脚本)

    在腾讯云买的那个1c2g的服务器,想用mycat搭建一个mysql cluser,用docker部署了一主一从内存就没了一半,可一主一从没啥作用,起码也得2主2从吧?而且还有HA呢,但内存和钱包不给力 ...

  2. 【AD21】软件基础

    1.AD21最后生成什么文件打板子? 生成gerber文件 2.一个工程包括什么? 原理图库,原理图,PCB库,PCB 3.距离单位? 默认是mil,1mm约为40mil 4.软件中PCB层? 表层焊 ...

  3. srcrpy手机投屏软件

    1,先在pc上下载和压缩投屏软件 2,在安卓手机上设置打开开发者模式 (usb是需要插线的,如果要无线连接就用adb)

  4. :)torch转onnx总结--|

    torch->onnx 参考:参考连接:https://blog.csdn.net/cxx654/article/details/123011332 1 安装 onnx >python - ...

  5. 在CIMES中调用存储过程

    页面 调用步骤 DataTable dtResult = null; CustomDataAgent TODB_con = DBCenter.Create(AppSetting.Manufacturi ...

  6. HybridCLR热更新方案

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

  7. C++并发编程实战(第2版)

    这本书翻译的烂,写的也不好. 甚至不如看cppreference. 这本书英文叫C++ Concurrency in Action, Second Edition 英文原版也是垃圾,C++实在没有写得 ...

  8. 【TensorFlow】Tensorflow-GPU 环境搭建教程(附 Windows 版本对应表及 CUDA GPU 计算能力表)

    conda教程(推荐):『Tensorflow GPU Installation Made Easy: Use conda instead of pip [Update-2] | by Harveen ...

  9. testtesttest

    test test       2022-09-24 #include<iostream> using namespace std; int main(){ cout<<&qu ...

  10. debian / deepin (Ubuntu)安装 mariadb

    debian / deepin 安装 mariadb 安装步骤: LINUX安装mariadb本质和mysql一致,可以参考官网教程进行安装.https://mariadb.org/download/ ...