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. kali对安卓的渗透(内网穿透)

    前言:随着移动端的增加,安卓占比巨大,人们对手机的安全防范意识薄弱,手机为了人们更加的方便,缺乏防护软件,甚至好多木马不需要做免杀. 现在我来做安卓的渗透,不需要在内网也能进行,实现了内网穿透.(有公 ...

  2. OS-lab4

    OS-lab4 系统调用 系统调用的流程 按照上述的流程逐个分析. user/syscall_lib.c 这个文件位于user文件夹下,也就是用户程序可以调用的函数,相当于操作系统提供给用户程序的一些 ...

  3. 12组-Beta冲刺-总结

    组长博客链接 https://www.cnblogs.com/147258369k/p/15615820.html 一.基本情况 1.1 现场答辩总结 柯老师意见: 面向普通用户群体推出排行榜功能 增 ...

  4. 808.11ac的MAC层

    MAC层是802.11的主要功能部分.上层应用通过调用MAC层提供的接口原语调用MAC层的功能. 在内部,MAC由除了函数还有数据,叫MIB,存储MAC的各种参数.SME是一个单独的模块,用来跟接口函 ...

  5. 用 go 实现多线程下载器

    本篇文章我们用Go实现一个简单的多线程下载器. 1.多线程下载原理 通过判断下载文件链接返回头信息中的 Accept-Ranges 字段,如果为 bytes 则表示支持断点续传. 然后在请求头中设置 ...

  6. django 关联类 DoesNotExist: User matching query does not exist.

    问题就是 关联类为空找不到 在或者geattr / hasattr / obj. item 会抛出异常 无法通过判断处理 捕获异常 try: tmp_data['demand_dept_name'] ...

  7. mysql压缩表小记

    参考文档: https://www.163.com/dy/article/GI4CH5N305319P76.html https://learn.lianglianglee.com/专栏/MySQL实 ...

  8. torch& tensorflow

    #torchimport torch import torch.nn as nn import torch.nn.functional as F class Net(nn.Module): def _ ...

  9. Jenkins自动化部署(linux环境)---执行脚本

    1.安装node插件 2.node全局配置 3.填写jenkins构建时执行的shell脚本 完整命令 node -v npm install rm -rf ./dist/* npm run buil ...

  10. 日志 LOG / Debug

    有很多时候我们想要查看日志文件,发现服务器已经被重启了,然后原来的日志就被打包存起来了,这个时候生成的gz日志文件我们就没有办法直接去查看了. 所以这个时候我们就需要zcat+日志名.gz来查看,还可 ...