【leetcode】Rotate Image
Rotate Image
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 n=matrix.size();
int leftUp=;
int rightBottom=n-;
while(rightBottom>leftUp)
{
int n0=rightBottom+leftUp;
for(int i=leftUp;i<rightBottom;i++)
{
int tmp=matrix[leftUp][i];
matrix[leftUp][i]=matrix[n0-i][leftUp];
matrix[n0-i][leftUp]=matrix[n0-leftUp][n0-i];
matrix[n0-leftUp][n0-i]=matrix[i][n0-leftUp];
matrix[i][n0-leftUp]=tmp;
}
leftUp++;rightBottom--;
}
}
};
【leetcode】Rotate Image的更多相关文章
- 【LeetCode】 Rotate List 循环链表
题目:rotate list 解法1: <span style="font-size:18px;">/**LeetCode Rotate List:Given a li ...
- 【leetcode】Rotate List(middle)
Given a list, rotate the list to the right by k places, where k is non-negative. For example:Given 1 ...
- 【leetcode】Rotate Image(middle)
You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). ...
- 【LeetCode】Rotate Array
Rotate Array Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = ...
- 【题解】【矩阵】【回溯】【Leetcode】Rotate Image
You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). ...
- 【LeetCode】Rotate List
Given a list, rotate the list to the right by k places, where k is non-negative. For example:Given 1 ...
- 【LeetCode】61. Rotate List 解题报告(Python)
[LeetCode]61. Rotate List 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fux ...
- 【LeetCode】数学(共106题)
[2]Add Two Numbers (2018年12月23日,review) 链表的高精度加法. 题解:链表专题:https://www.cnblogs.com/zhangwanying/p/979 ...
- 【LeetCode】双指针 two_pointers(共47题)
[3]Longest Substring Without Repeating Characters [11]Container With Most Water [15]3Sum (2019年2月26日 ...
随机推荐
- centos 7.0 nginx 1.7.9 安装过程
系统用的是centos 7.0最小化安装 我现在安装完了 写一下步骤 还没完全搞懂 首先安装GCC [root@localhost ~]# yum install -y gcc gcc-c++ 已加载 ...
- layoutSubviews方法需要被调用的情况有哪些
layoutSubviews方法:这个方法,默认没有做任何事情,需要子类进行重写 layoutSubviews在以下情况下会被调用: 1.init初始化不会触发layoutSubviews 但是是用i ...
- VS2015新建asp.net core站点
摘要 电脑上安装了vs2015,今天就尝尝鲜,新建一个项目试试. BBS 使用vs2015新建一个解决方案,然后新建项目,此时你会发现没有asp.net core项目,这就需要先安装asp.net c ...
- 【转载】linux lftp命令 详解
站在前辈的肩上,别人会的你要尽快的学会练好! lftp比ftp要好用,mget的时候,迹象要比较明显的迹象,比如下载进度! linux lftp命令 1.登录ftp代码:lftp 用 ...
- linq/EF/lambda 比较字符串日期时间大小
在使用EF时,想要比较字符串类型的日期时,参考以下: SQL语句: 1 2 3 4 1)select * from TableName where StartTime > '2015-04-08 ...
- asp.net mvc 实现博客的时间分类管理
先看效果 这个其实用c#实现起来比较简单: Sides = bllSession.IArticleBLL.GetList("") .Select(a => a.Time) . ...
- ThinkPHP的四种URL模式 URL_MODEL
ThinkPHP支持四种URL模式,可以通过设置URL_MODEL参数来定义,包括普通模式.PATHINFO.REWRITE和兼容模式. 普通模式 设置URL_MODEL 为0 采用传统的URL参数模 ...
- wtforms 使用
wtforms是一个表单模板库, 下面以修改密码表单为例简单说明其用法. 我们可以用python代码定义form的基本元素, 比如用户名/邮箱, 并给定各个元素的validation条件. 然后在re ...
- 【翻译】Tomcat 6.0 部署与发布
本篇参考Tomcat官方文档:<First Webapp>翻译,并结合自己的开发经验介绍关于tomcat部署以及发布的相关内容. 1 目录结构 在tomcat中所有的应用都是放置在CATA ...
- 只会CSS还不够,LESS、SASS、BootStrap、Foundation一网打尽!
有些人想学CSS,不知如何下手:有些人已经学会CSS的各种属性,却不知如何运用:有些人会平面设计,不知道如何与网页设计结合:有些人会HTML,就是学不会CSS.试问自己,图中的技术你都会了吗? 别总是 ...