48. Rotate Image via java
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的更多相关文章
- [Leetcode][Python]48: Rotate Image
# -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 48: Rotate Imagehttps://leetcode.com/pr ...
- [array] leetcode - 48. Rotate Image - Medium
leetcode - 48. Rotate Image - Medium descrition You are given an n x n 2D matrix representing an ima ...
- 刷题48. Rotate Image
一.题目说明 题目是48. Rotate Image,简而言之就是矩阵顺时针旋转90度.不允许使用额外的矩阵. 经过观察(写一个矩阵,多看几遍就知道了),旋转90度后: 第1行变为len-1列(最后一 ...
- 48. Rotate Image - LeetCode
Question 48. Rotate Image Solution 把这个二维数组(矩阵)看成一个一个环,循环每个环,循环每条边,每个边上的点进行旋转 public void rotate(int[ ...
- 48. Rotate Image
题目: You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwis ...
- LeetCode OJ 48. Rotate Image
You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). ...
- LeetCode 48. Rotate Image(旋转图像)
You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). ...
- LeetCode算法题-Rotate String(Java实现)
这是悦乐书的第317次更新,第338篇原创 在开始今天的算法题前,说几句,今天是世界读书日,推荐两本书给大家,<终身成长>和<禅与摩托车维修艺术>,值得好好阅读和反复阅读. 0 ...
- LeetCode算法题-Rotate Array(Java实现)
这是悦乐书的第184次更新,第186篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第43题(顺位题号是189).给定一个数组,将数组向右旋转k步,其中k为非负数.例如: ...
- [LeetCode] 48. Rotate Image 旋转图像
You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). ...
随机推荐
- Django安装与启动
安装 python -m pip install Django 查看版本 python -m django --version打开命令行,cd 到一个你想放置你代码的目录,然后运行以下命令: dja ...
- Linux 第十节( APACHE )
Apache 基金会,软件 http 协议 httpd 软件包 vim /etc/httpd/conf/httpd.conf //网站配置主文件 systemctl restart http ...
- CSMA/CA多路复用、载波监听、冲突避免
CSMA/CA是避免各站点之间数据传输冲突的算法,其特点是发送包的同时不能检测到信道上有无冲突,只能尽量"避免".例如,如果计算机A和计算机C同时给计算机B发送一个控制消息,它们将 ...
- 个人css样式
<style> .div1{ width:200px; height:100px; border:1px solid #dddddd; transition:all 0.5s linear ...
- selenium------关于switch_to的用法场景
基于python3的语法,driver.switch_to_alert()的表达会出现中划线,因此需要把后面的下划线改为点.一.目前接触到的switch_to的用法包括以下几种:1. 切换到制定的wi ...
- docker-compose任务编排
一.docker-compose介绍 使用一个Dockerfile模板文件可以定义一个单独的应用容器,如果需要定义多个容器就需要服务编排.下面介绍Docker官方产品,Docker Compose. ...
- Jupyter notebook upload无法加载本地ipynb文件
可能是本地浏览器(IE)问题,修改默认浏览器.
- 1067- invalid default value for ""
创建表时报的,一个时间字段类型是datetime,一保存就报错,网上说是datetime类型只支持mysql 5.6.5+,我看了下我的版本,5.8的,没什么问题,然后找了许久找到了错误的地方. 很蠢 ...
- shell mv cp image in parallel 多线程解压parallel
# apt install parallel # mkdir -p 1Kx1K/img # ls 1Kx1K/img_9*.jpg |parallel -j 80 mv {} 1Kx1K/img ht ...
- ICPC2021 沈阳站
B-Bitwise Exclusive-OR Sequence 牛客网 题意:对于\(n(n<=1*10^5)\)个数的序列,给定\(m(m<=2*10^5)\)个限制条件,每个限制条件形 ...