Rotate Image
来源:互联网 发布:廊坊百度快照优化推广 编辑:程序博客网 时间:2024/05/16 04:06
Q:
You are given an n x n 2D matrix representing an image.
Rotate the image by 90 degrees (clockwise).
Follow up:
Could you do this in-place?
Solution:
public 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-1-i; j++) { int temp = matrix[j][i]; matrix[j][i] = matrix[n-1-i][j]; matrix[n-1-i][j] = matrix[n-1-j][n-1-i]; matrix[n-1-j][n-1-i] = matrix[i][n-1-j]; matrix[i][n-1-j] = temp; } } }}
0 0
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- Rotate Image
- IOS开发之__bridge,__bridge_transfer和__bridge_retained
- CFH
- maven上传jar到私服
- searchBa牛逼文档
- UITableView 一直显示滚动条(ScrollBar Indicators)、滚动条Width(宽度)、滚动条Color(颜色)
- Rotate Image
- java cup占用高分析脚本
- 1024! 末尾有多少个0?
- 发布-订阅消息模式
- hdu 1000 A + B Problem
- 多个github帐号的SSH key切换
- BZOJ 1011 HNOI2008 遥远的行星 递推
- Andriod UI 事件监听
- UVA-10245 The Closest Pair Problem(最近点对问题)