Leetcode每日一题:48.rotate-image(旋转图像)
思路:
//旋转
void rotate(vector<vector<int>> &matrix)
{int len = matrix.size();for (int start = 0, end = len - 1; start < end; start++, end--){for (int s = start, e = end; s < end; s++, e--){int temp = matrix[start][s];matrix[start][s] = matrix[e][start];matrix[e][start] = matrix[end][e];matrix[end][e] = matrix[s][end];matrix[s][end] = temp;}}
}
void rotate(vector<vector<int>> &matrix)
{int len = matrix.size();//上下翻转for (int i = 0; i < len / 2; i++){for (int j = 0; j < len; j++){int temp = matrix[i][j];matrix[i][j] = matrix[len - 1 - i][j];matrix[len - 1 - i][j] = temp;}}//转置for (int x = 0; x < len; x++){for (int y = x; y < len; y++){int temp = matrix[y][x];matrix[y][x] = matrix[x][y];matrix[x][y] = temp;}}
}
Leetcode每日一题:48.rotate-image(旋转图像)相关推荐
- leetcode每日刷题计划-简单篇day8
leetcode每日刷题计划-简单篇day8 今天是纠结要不要新买手机的一天QAQ想了想还是算了吧,等自己赚钱买,加油 Num 70 爬楼梯 Climbing Stairs class Solutio ...
- Leetcode每日一题:171.excel-sheet-column-number(Excel表列序号)
思路:就是168题的反命题,进制的方式完美解决: Leetcode每日一题:168.excel-sheet-column-title(Excel表名称) class Solution {public: ...
- 【LeetCode每日一题】1723. 完成所有工作的最短时间
[LeetCode每日一题]1723. 完成所有工作的最短时间 [1] 1723. 完成所有工作的最短时间 [2] 473. 火柴拼正方形 [1] 1723. 完成所有工作的最短时间 题目: 给你一个 ...
- leetcode每日一题--雀巢原理;抽屉算法;Quorum机制;分布式应用
leetcode每日一题 539. 最小时间差 示例 1: 输入:timePoints = ["23:59","00:00"] 输出:1 示例 2: 输入:ti ...
- LeetCode每日一题——1812. 判断国际象棋棋盘中一个格子的颜色
LeetCode每日一题系列 题目:1812. 判断国际象棋棋盘中一个格子的颜色 难度:简单 文章目录 LeetCode每日一题系列 题目 示例 思路 题解 题目 给你一个坐标 coordinates ...
- 【LeetCode每日一题】——109.有序链表转换二叉搜索树
文章目录 一[题目类别] 二[题目难度] 三[题目编号] 四[题目描述] 五[题目示例] 六[题目提示] 七[解题思路] 八[时间频度] 九[代码实现] 十[提交结果] 一[题目类别] 二叉树 二[题 ...
- leetcode每日一题·救生艇问题(Python)
leetcode每日一题·救生艇问题(Python) 问题描述 题目入口 题目思路 首先分析问题,一个船最多坐两人,因此我们可以把这个问题看作两两组合的问题,并且如果最重的那个人和最轻的人加起来大于l ...
- LeetCode每日一题——904. 水果成篮
LeetCode每日一题系列 题目:904. 水果成篮 难度:普通 文章目录 LeetCode每日一题系列 题目 示例 思路 题解 题目 你正在探访一家农场,农场从左到右种植了一排果树.这些树用一个整 ...
- LeetCode每日一题打卡组队监督!刷题群!
近 2000 人已经加入共同刷题啦! 群友每天都会在群里给大家讲解算法题 每周日「负雪明烛」组织直播讲题 我相信来看我博客的大部分人都是通过LeetCode刷题过来的.最近发现LeetCode中文网站 ...
最新文章
- 博客园程序源代码下载
- win7 计算器 android,教你巧妙应用Win7计算器和时钟
- 解决:com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column ‘ip‘ at row 1
- 神秘的40毫秒延迟与 TCP_NODELAY
- 关于java mail 发邮件的问题总结(转)
- python xlutils教程_python xlutils复制表格使用方法
- C#匿名委托,匿名函数,lambda表达式
- java一千_涨姿势:为什么Java中“1000=1000”为false,而”100=100“为true?
- 数字IC设计学习笔记_专业书单整理
- Redis安装部署(Windows/Linux)
- java excel 日期格式转换_Java处理Excel中的日期格式
- 敏捷软件开发第26章STAIRWAY TO HEAVEN设计模式C++源码
- 天津仁爱学院ACM工作室简介
- 推荐系统实践(三)ICF和UCF
- java都市男人心痒痒_男人最想听的情话不是我爱你那是什么 说的男人心痒痒的情话大全...
- 《密码安全新技术》课程总结报告
- Anbox之构建android.img(三)
- python 安装问题
- overflow的属性值说明
- 几种 VR 的数据传输方案