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. svn 中如何checkout出单个文件

    A 通过命令行操作 1.检出目录images svn co --depth=empty http://www.iusesvn.com/project1/images images_work_dir 这 ...

  3. 攻防世界-fileclude

    攻防世界的一道文件包含题目 include("文件名"):会将文件中的内容视为代码块接入include所在代码中,输出的只是执行后的结果,文件中的注释.定义等无法查看. 本题中可以 ...

  4. win10格式化U盘提示没有权限执行此操作

    解决办法参考:http://www.tpbz008.cn/post/766.html 1.gpedit.msc 2.展开计算机配置,管理模板.展开系统.选中可移动存储访问 3.所有可移动存储类:拒绝所 ...

  5. DOS批处理自动定期清除生成的备份文件

    此功能实现生产环境自动定期清除备份文件. @echo off rem 功能:只保留7天的备份,每天运行. rem 日期:2022.8.15 rem 制作人:zl rem 自动删除7天前的备份 rem ...

  6. 安装oracle出现环境不满足最低要求

    安装win64_11gR2_database_1of2的时候出现这个,百度了下解决方法 在oracle安装包找到stage文件夹 然后找到cvu 然后在cvu里面找到cvu_prereq,用记事本打开 ...

  7. Centos 8 安装zabbix 爬坑

    1.安装mininal 8 2.配置静态网络BOOTPROTO=staticIPADDR=192.168.2.1NETMASK=255.255.255.0GATEWAY=192.168.2.200DN ...

  8. k8s_使用k8s部署wordpress博客系统(一)

    系统部署流程 使⽤kubernetes部署wordpress+MySQL, 并利⽤NFS去保存我们容器的源代码以及DB数据.搭建好nfs后任意node上的Pod访问db或者业务代码都会有相同的效果,数 ...

  9. centos 更新git

    yum remove git rpm -ivh http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-1. ...

  10. /usr/bin/install: cannot create regular file `/usr/local/jpeg6/include/jconfig.h'

    出现下列异常: /usr/bin/install -c -m 644 jconfig.h /usr/local/jpeg6/include/jconfig.h /usr/bin/install: ca ...