首页
题库
面试
求职
学习
竞赛
More+
所有博客
搜索面经/职位/试题/公司
搜索
我要招人
去企业版
登录 / 注册
首页
>
试题广场
>
旋转图像
[编程题]旋转图像
热度指数:12117
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 32M,其他语言64M
算法知识视频讲解
给出一个用二维矩阵表示的图像
返回该图像顺时针旋转90度的结果
扩展:
你能使用原地算法解决这个问题么?
马上挑战
算法知识视频讲解
提交运行
算法知识视频讲解
添加笔记
求解答(0)
邀请回答
收藏(72)
分享
提交结果有问题?
75个回答
2篇题解
开通博客
华科不平凡
发表于 2020-09-05 18:03:25
这一问题可以有如下问法(都是空间复杂度为常数级别): 矩阵左旋/右旋90度 矩阵左旋/右旋180度 对于本题,有两种思路: 思路一:利用对称进行旋转——先根据主对角线互换元素,再根据垂直中线互换元素 思路二:利用坐标映射 强烈建议用第一种方法,因为找第二种方法的坐标关系特别特别特别麻烦
展开全文
牛客710153440号
发表于 2025-09-08 16:59:21
#include <vector> class Solution { public: void rotate(vector<vector<int> > &matrix) { if(matrix.empty()) return;
展开全文
问题信息
数组
难度:
75条回答
72收藏
17483浏览
热门推荐
通过挑战的用户
查看代码
牛客77022...
2022-11-10 10:27:03
我在人间混日子
2022-08-27 18:39:18
Varus20...
2022-08-20 16:31:58
牛客92292...
2022-06-27 10:37:51
牛客40159...
2022-06-27 10:16:51
相关试题
以下 Python 代码的输出是什么?
Python
评论
(1)
Choose the best w...
英语语法
评论
(1)
小O的字符串重排
字符串
贪心
OPPO
评论
(1)
小O的子序列最值
排序
OPPO
二分
评论
(2)
小O的整数操作
贪心
OPPO
基础数学
评论
(0)
旋转图像
扫描二维码,关注牛客网
意见反馈
下载牛客APP,随时随地刷题
import java.util.*; public class Solution { public void rotate(int[][] matrix) { } }
class Solution { public: void rotate(vector
> &matrix) { } };
# # # @param matrix int整型二维数组 # @return void # class Solution: def rotate(self , matrix ): # write code here
/** * * @param matrix int整型二维数组 * @return void */ function rotate( matrix ) { // write code here } module.exports = { rotate : rotate };
# # # @param matrix int整型二维数组 # @return void # class Solution: def rotate(self , matrix ): # write code here
package main /** * * @param matrix int整型二维数组 * @return void */ func rotate( matrix [][]int ) { // write code here }
/** * * @param matrix int整型二维数组 * @param matrixRowLen int matrix数组行数 * @param matrixColLen int* matrix数组列数 * @return void */ void rotate(int** matrix, int matrixRowLen, int* matrixColLen ) { // write code here }