博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Rotate Image
阅读量:7130 次
发布时间:2019-06-28

本文共 722 字,大约阅读时间需要 2 分钟。

Question:

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?

  to see which companies asked this question

可以先旋转最外围一层,然后依次旋转里层:

1 class Solution { 2 public: 3     void rotate(vector
>& matrix) { 4 int N=matrix.size(); 5 for(int layer=0;layer
top14 matrix.at(last-offset).at(first)=matrix.at(last).at(last-offset); //bottom->left15 matrix.at(last).at(last-offset)=matrix.at(i).at(last); //right->bottom16 matrix.at(i).at(last)=top; //top->right17 }18 }19 20 }21 };

 

转载于:https://www.cnblogs.com/mrlsx/p/5431334.html

你可能感兴趣的文章
xshll登录脚本
查看>>
让“云”无处不在-Citrix Xenserver之一 环境搭建
查看>>
IT 工具软件集合
查看>>
KVM虚拟化原理与实践
查看>>
WSFC 来宾群集架构
查看>>
快速寻找某IP地址所在的网络交换机端口 - Netdisco
查看>>
51CTO广东线下聚会-技术达人之夜总结篇
查看>>
Git 之——常用命令集合
查看>>
DNS服务器bind的架设笔记
查看>>
CentOS启动提示unexpected inconsistency;RUN fsck MANUALLY解决方法
查看>>
一个问题看系统数据库设计
查看>>
镜像仓库Harbor私服高可用策略分析及部署
查看>>
重写cnodejs学习整理
查看>>
从浏览器渲染的角度谈谈html标签的语义化
查看>>
文件权限及特殊权限管理SUID、SGID和Sticky
查看>>
iis 7 asp.net ajax post 请求字节过大报错问题解决办法
查看>>
高仿腾讯QQ即时通讯IM项目
查看>>
winform 中xml简单的创建和读取
查看>>
活动设计的“七宗罪”(转)
查看>>
如何在ChemDraw中输入℃温度符号
查看>>