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?

class Solution {
public:
void rotate(vector<vector<int> > &matrix) {
int temp;
for(int i = ; i < matrix.size()/; i++)
{
for(int j = i; j < matrix[].size()-i-; j++)
{
temp = matrix[i][j];
matrix[i][j] = matrix[matrix[].size()--j][i];
matrix[matrix[].size()--j][i] = matrix[matrix.size()--i][matrix.size()--j];
matrix[matrix.size()--i][matrix.size()--j] = matrix[j][matrix.size()--i];
matrix[j][matrix.size()--i] = temp;
}
}
}
};

48. Rotate Image (Array)的更多相关文章

  1. [array] leetcode - 48. Rotate Image - Medium

    leetcode - 48. Rotate Image - Medium descrition You are given an n x n 2D matrix representing an ima ...

  2. [Leetcode][Python]48: Rotate Image

    # -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 48: Rotate Imagehttps://leetcode.com/pr ...

  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. LeetCode 48. Rotate Image(旋转图像)

    You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). ...

  6. 1. 数组小挪移CyclicRotation Rotate an array to the right by a given number of steps.

    数组小挪移: package com.code; import java.util.Arrays; public class Test02_2 { public int[] solution(int[ ...

  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 48] rotate image

    1 题目 You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwi ...

  9. 48. Rotate Image

    题目: You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwis ...

随机推荐

  1. 『转』Panda Antivirus Pro 2014 – 免费6个月

    Panda Antivirus Pro 2014 为您的计算机提供了最简单的使用和最直观的保护.最近,Panda公司和 softonic公司合作推出免费半年版本活动地址:点此进入点击“Kostenlo ...

  2. New Concept English Two 15 37

    listening speaking reading writing and translating $课文35  捉贼! 355. Roy Trenton used to drive a taxi. ...

  3. C# 实现网络时间同步功能

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.I ...

  4. mongodb数据处理工具

    最近大家需要对mongodb和postgres数据库操作比较频繁,给大家推荐一个数据处理工具Kettle,希望对你能有所帮助 ①   将mongodb数据库中的表进行处理然后导出来生成csv,txt, ...

  5. UOJ 55 【WC2014】紫荆花之恋——点分治+平衡树

    题目:http://uoj.ac/problem/55 点分治.在点分树上每个点上用 splay 维护管辖的点的情况.做几次就重构点分树.TLE.只能过 20 分. #include<cstdi ...

  6. Tomcat 性能优化(连接数、线程、JVM、dir)

    Tomcat的server.xml中Context元素的以下参数应该怎么配合适 <Connector port="8080" maxThreads="150&quo ...

  7. SQL注入与安全防护---以PHP为例

    一.什么是sql注入: 简单来说,当我们从前端的用户表单数据往后台数据库传输时,可能用户表单数据中的某些数据,会跟我们的后台发生“有机”反应,从而导致发生一些数据库的异常操作. 举个例子吧,以简单的用 ...

  8. laravel 控制器中使用 try catch

    需要操作数据库时,当数据字段不一致,mysql报错,控制程序,需要使用try catch 下面是使用案例 $morder['morder_time'] = time();//在这里使用try catc ...

  9. SQL中利用脚本创建database mail.

    SQL中利用脚本创建database mail   编写人:CC阿爸 2014-6-14 多话不讲,请参考以下脚本 use  

  10. cocos2d-x 3.0 场景切换特效汇总(转)

    cocos2d-x 3.0中场景切换特效比较多,而且游戏开发中也经常需要用到这些特效,来使场景切换时不至于那么干巴,遂这里汇总一下,开发中使用. 场景切换用到导演类Directory,大多数用的都是替 ...