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. java基础第9天

    抽象 abstract 抽象类和抽象方法必须用abstract关键字修饰 抽象类格式 abstract class 类名{} 抽象方法定义,在返回值钱,或修饰符前加上abstract关键字 方法没有方 ...

  2. React Native自适应设备宽度解决方案

    px:设备实际像素单位 dp/pt:逻辑像素单位(IOS的尺寸单位为pt,Android的尺寸单位为dp) 在设计和开发过程中,应该尽量使用逻辑像素尺寸来思考界面. UI 给默认 640 的图,采用 ...

  3. js 验证手机号码

    js 验证手机号码 //验证手机号        function isMobel(value) {           if (/^1[3-8]+\d{9}$/g.test(value)) {    ...

  4. 中南林业科技大学第十一届程序设计大赛-C:有趣的二进制

    链接:https://www.nowcoder.com/acm/contest/124/C来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 131072K,其他语言26214 ...

  5. WPF 多线程 UI:设计一个异步加载 UI 的容器

    对于 WPF 程序,如果你有某一个 UI 控件非常复杂,很有可能会卡住主 UI,给用户软件很卡的感受.但如果此时能有一个加载动画,那么就不会感受到那么卡顿了.UI 的卡住不同于 IO 操作或者密集的 ...

  6. [LOJ6198]谢特

    loj description 给你一个字符串和一个数组\(w_i\),定义\(\mbox{LCP}(i,j)\)为\(i,j\)两个后缀的最长公共前缀.求\(\max_{i,j}\mbox{LCP} ...

  7. C# 与 Oracle 中 BINARY_DOUBLE数据类型查询

    Oracle 10g新增 BINARY_DOUBLE 数据类型,而.NET暂不支持这个类型,查询时需要转换为 NUMBER. eg: "SELECT RAWTOHEX(OID) AS OID ...

  8. charles手机抓包配置-2

    破解的安装包,自己的百度云里有收藏 http://www.zhimengzhe.com/IOSkaifa/248398.html http://blog.csdn.net/swj6125/articl ...

  9. 把MacBook里的电影导入到iPad

    主要是用iTunes -> 文件 -> 添加到资料库,然后选择影片 -> 同步 -> 应用.在iPad上点开视频APP即可. 怎样才能把mac里的电影放到ipad里_百度知道 ...

  10. TCL数组

    数组是一组使用索引对应元素的排列方式.常规数组的语法如下所示. set ArrayName(Index) value 用于创建简单数组的例子,如下所示. #!/usr/bin/tclsh set la ...