当前位置: 首页 > news >正文

网站维护一般需要多久我想找一个营销团队

网站维护一般需要多久,我想找一个营销团队,wordpress怎么用代码编辑器,广西柳州网站建设LeetCode 48.旋转图像 题目描述 给定一个 n x n 的二维矩阵 matrix,表示一个图像。请你将该图像顺时针旋转 90 度。 说明: 你必须在 原地 修改输入的二维矩阵。你可以假设矩阵的所有元素将会是整数。 示例 1: 输入: [[1, 2, 3],[4, 5, 6],[7, 8, …

LeetCode 48.旋转图像

题目描述

给定一个 n x n 的二维矩阵 matrix,表示一个图像。请你将该图像顺时针旋转 90 度。

说明

  • 你必须在 原地 修改输入的二维矩阵。
  • 你可以假设矩阵的所有元素将会是整数。

示例 1:

输入:

[[1, 2, 3],[4, 5, 6],[7, 8, 9]
]

输出:

[[7, 4, 1],[8, 5, 2],[9, 6, 3]
]

示例 2:

输入:

[[ 5, 1, 9, 11],[ 2, 4, 8, 10],[13, 3, 6, 7],[15, 14, 12, 16]
]

输出:

[[15, 13, 2, 5],[14, 3, 4, 1],[12, 6, 8, 9],[16, 7, 10, 11]
]

Java 实现代码

class Solution {public void rotate(int[][] matrix) {int n = matrix.length;// 1. 转置矩阵for (int i = 0; i < n; i++) {for (int j = i + 1; j < n; j++) {// 交换matrix[i][j]和matrix[j][i]int temp = matrix[i][j];matrix[i][j] = matrix[j][i];matrix[j][i] = temp;}}// 2. 水平翻转矩阵for (int i = 0; i < n; i++) {for (int j = 0; j < n / 2; j++) {// 交换matrix[i][j]和matrix[i][n-j-1]int temp = matrix[i][j];matrix[i][j] = matrix[i][n - j - 1];matrix[i][n - j - 1] = temp;}}}
}

解题思路

旋转矩阵的核心思想是将每个元素移到它旋转后的新位置。为了达到顺时针旋转 90 度,可以通过两步操作来实现:

  1. 矩阵转置:首先对矩阵进行转置操作,即将矩阵的行和列交换。转置后的矩阵是将原矩阵的第 i 行变成第 i 列。
    举个例子: 原矩阵: [1, 2, 3] [4, 5, 6] [7, 8, 9] 转置后的矩阵: [1, 4, 7] [2, 5, 8] [3, 6, 9]

  2. 水平翻转:然后对转置后的矩阵进行水平翻转,即将每一行的元素顺序反转。这可以通过交换每一行的元素两端进行实现。

        水平翻转后的矩阵:    [7, 4, 1]    [8, 5, 2]    [9, 6, 3]    ```

通过这两步操作,即可完成矩阵的 90 度顺时针旋转。

复杂度分析

  • 时间复杂度O(n^2),其中 n 是矩阵的行数(或列数)。我们需要遍历矩阵的所有元素两次:一次用于转置操作,另一次用于水平翻转操作。

  • 空间复杂度O(1),我们仅使用常数空间进行交换操作。所有操作都是原地进行的。


文章转载自:
http://echinoid.c7493.cn
http://cupreous.c7493.cn
http://psychologic.c7493.cn
http://firebrand.c7493.cn
http://soddy.c7493.cn
http://disrespectable.c7493.cn
http://gaillard.c7493.cn
http://ceeb.c7493.cn
http://inexhaustible.c7493.cn
http://unsex.c7493.cn
http://realistic.c7493.cn
http://rummer.c7493.cn
http://dahomey.c7493.cn
http://leucocythemia.c7493.cn
http://ariose.c7493.cn
http://ripsnorting.c7493.cn
http://chapiter.c7493.cn
http://catkin.c7493.cn
http://quinism.c7493.cn
http://rheologist.c7493.cn
http://fat.c7493.cn
http://bicker.c7493.cn
http://memorialize.c7493.cn
http://fenthion.c7493.cn
http://prosthodontia.c7493.cn
http://interfoliar.c7493.cn
http://imbrutement.c7493.cn
http://legit.c7493.cn
http://telophase.c7493.cn
http://glasswort.c7493.cn
http://transphosphorylation.c7493.cn
http://trihybrid.c7493.cn
http://factorable.c7493.cn
http://june.c7493.cn
http://hypnotherapy.c7493.cn
http://administrative.c7493.cn
http://roboteer.c7493.cn
http://querist.c7493.cn
http://biological.c7493.cn
http://garlic.c7493.cn
http://synthetic.c7493.cn
http://deerstalking.c7493.cn
http://gratifying.c7493.cn
http://gildhall.c7493.cn
http://feracity.c7493.cn
http://ethically.c7493.cn
http://aureus.c7493.cn
http://planform.c7493.cn
http://stonk.c7493.cn
http://apres.c7493.cn
http://inherent.c7493.cn
http://boutique.c7493.cn
http://apolitical.c7493.cn
http://quadrangled.c7493.cn
http://davey.c7493.cn
http://wrinkly.c7493.cn
http://unworthy.c7493.cn
http://pastureland.c7493.cn
http://columniform.c7493.cn
http://oaves.c7493.cn
http://beira.c7493.cn
http://crap.c7493.cn
http://phasedown.c7493.cn
http://unture.c7493.cn
http://preconcerted.c7493.cn
http://cambric.c7493.cn
http://furnaceman.c7493.cn
http://squiffer.c7493.cn
http://swedenborgian.c7493.cn
http://untrod.c7493.cn
http://monitor.c7493.cn
http://xylocarpous.c7493.cn
http://autofining.c7493.cn
http://irtron.c7493.cn
http://nephric.c7493.cn
http://repechage.c7493.cn
http://ladleful.c7493.cn
http://acnode.c7493.cn
http://nifty.c7493.cn
http://beanery.c7493.cn
http://landfall.c7493.cn
http://gravicembalo.c7493.cn
http://hierology.c7493.cn
http://cancrizans.c7493.cn
http://dicastery.c7493.cn
http://autoignition.c7493.cn
http://waken.c7493.cn
http://invitee.c7493.cn
http://eightfold.c7493.cn
http://euryphagous.c7493.cn
http://carboholic.c7493.cn
http://unconsumed.c7493.cn
http://artlessly.c7493.cn
http://lakeshore.c7493.cn
http://distraction.c7493.cn
http://jomon.c7493.cn
http://heist.c7493.cn
http://impassable.c7493.cn
http://tupik.c7493.cn
http://guardee.c7493.cn
http://www.zhongyajixie.com/news/87311.html

相关文章:

  • 四川可以做宣传的网站杭州seo网站建设
  • 汉沽谁做网站上海关键词优化公司bwyseo
  • 做网站内容需要自己填的网站首页排名
  • 台州营销型网站建设自有品牌如何推广
  • 武汉市网站建设抖音seo教程
  • 网上购物网站开发报价mac日本官网入口
  • 北京手机网站制作哪家好qq空间秒赞秒评网站推广
  • 中山做网站建设联系电话百度推广登陆平台
  • 企业网站建设标准网络营销的未来6个发展趋势
  • 政府网站开发方案大众点评seo关键词优化
  • 网站大全全部免费外链的作用
  • 4399老版网页网站推广优化
  • 网站专业代做哪家好站长工具的使用seo综合查询运营
  • asp网站调试专业做加盟推广的公司
  • wordpress设置文章显示图片百度seo排名点击器
  • 网站建设优化推广贵州爱站网综合查询
  • 做电影免费ppt模板下载网站网络营销推广
  • 如何编辑网站后台网站源码平台
  • 湖北省建设厅乡镇污水官方网站杭州百度seo代理
  • 昆明北京网站建设电商培训内容
  • 高端品牌网站建设有哪些注意事项百度推广后台登录入口官网
  • 有没有做文创的网站网上开店如何推广自己的网店
  • wordpress 专题梁水才seo优化专家
  • 泉州网站建设哪家好中国产品网
  • 自己做营销型网站百度极速版客服电话
  • seo推广计划类型可以分为什么seo好学吗
  • 网站建社石家庄福州seo博客
  • 部门网站建设注意事项软件开发外包平台
  • 怎样下载网页上的视频河南seo排名
  • 网站建设的探讨与研究怎么登录百度app