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. 001. html篇之《基础内容》

    html基础内容 1. 什么是html Hypertext Markup Language 超文本标记语言 2. 基本结构 <!DOCTYPE html> <!-- 此为html5的 ...

  2. 使用Apache PDFBox实现拆分、合并PDF

    目录 使用Apache PDFBox实现拆分.合并PDF 问题背景 Apache PDFBox介绍 拆分PDF 合并PDF 拆分 + 合并 完整代码 参考: 使用Apache PDFBox实现拆分.合 ...

  3. (0303)《计算机体系结构 量化研究方法》PDF

    (01) https://blog.csdn.net/konghhhhh/article/details/106828402  存储器相关 (1) https://blog.csdn.net/iva_ ...

  4. Django操作mongo数据库一(配置文件里写连接信息)

    一.基本环境 1.开发环境: Python环境:Python 3.8.16 Django环境:4.1 2.需要安装的包 pip install pymongo pip install mongoeng ...

  5. VC如何创建C编译器能使用的动态库

    方法 使用extern "C"修饰 设置统一的调用约定 举例 例1--使用__cdecl,一般C编译器使用此约定,如LabWidnows/CVI. cpp代码 extern &qu ...

  6. thirty-one

    动态组件 动态切换组件的显示和隐藏 如何实现动态组件的渲染 vue提供了有一个内置的<component>组件,专门用来实现动态组件的渲染.示例代码如下: 使用keep-alive保持状态 ...

  7. PGI 用户手册之 Site-Specific Customization of the Compilers

    翻译自PGI Compiler User's Guide 1.6. 使用PGI编译器进行并行编程 PGI编译器支持多种样式的并行编程: 使用pgf77,pgf95,pgfortran,pgcc或pgc ...

  8. pdf2docx:可将 PDF 转换成 docx 文件的 Python 库

    pdf2docx:https://github.com/dothinking/pdf2docx 可将 PDF 转换成 docx 文件的 Python 库. from pdf2docx import p ...

  9. js数组的创建、添加、删除、获取指定元素下标

    数组: 1.数组内可以存放任意类型的数据 2.数组元素不赋值,则为undefined 3.打印数组时,如果某个元素没有赋值,则为"" 4.访问数组范围以外的元素时,不会出现越界异常 ...

  10. unity tex2Dlod in vert

    https://forum.unity.com/threads/how-to-sample-a-texture-in-vertex-shader.513816/   GreatWall said: ↑ ...