题目链接:https://leetcode-cn.com/problems/transpose-matrix/

给定一个矩阵 A, 返回 A 的转置矩阵。

矩阵的转置是指将矩阵的主对角线翻转,交换矩阵的行索引与列索引。

示例 1:

输入:[[1,2,3],[4,5,6],[7,8,9]]
输出:[[1,4,7],[2,5,8],[3,6,9]]
示例 2:

输入:[[1,2,3],[4,5,6]]
输出:[[1,4],[2,5],[3,6]]

提示:

1 <= A.length <= 1000
1 <= A[0].length <= 1000

 class Solution {
public int[][] transpose(int[][] A) {
int[][] newA=new int[A[0].length][A.length];
for(int i=0;i<A.length;i++){
for(int j=0;j<A[0].length;j++){
newA[j][i]=A[i][j];
}
}
return newA;
}
}

LeetCode 867. 转置矩阵的更多相关文章

  1. LeetCode(867)

    title: LeetCode(867) tags: Python Algorithm 题目描述 给定一个矩阵 A, 返回 A 的转置矩阵. 矩阵的转置是指将矩阵的主对角线翻转,交换矩阵的行索引与列索 ...

  2. Leetcode#867. Transpose Matrix(转置矩阵)

    题目描述 给定一个矩阵 A, 返回 A 的转置矩阵. 矩阵的转置是指将矩阵的主对角线翻转,交换矩阵的行索引与列索引. 示例 1: 输入:[[1,2,3],[4,5,6],[7,8,9]] 输出:[[1 ...

  3. LeetCode 867 Transpose Matrix 解题报告

    题目要求 Given a matrix A, return the transpose of A. The transpose of a matrix is the matrix flipped ov ...

  4. leetcode之转置矩阵

    转置矩阵 题目描述: 给定一个矩阵 A, 返回 A 的转置矩阵. 矩阵的转置是指将矩阵的主对角线翻转,交换矩阵的行索引与列索引. 示例 1: 输入:[[1,2,3],[4,5,6],[7,8,9]] ...

  5. 领扣(LeetCode)转置矩阵 个人题解

    给定一个矩阵 A, 返回 A 的转置矩阵. 矩阵的转置是指将矩阵的主对角线翻转,交换矩阵的行索引与列索引. 示例 1: 输入:[[1,2,3],[4,5,6],[7,8,9]] 输出:[[1,4,7] ...

  6. [LeetCode] 867. Transpose Matrix_Easy

    Given a matrix A, return the transpose of A. The transpose of a matrix is the matrix flipped over it ...

  7. Leetcode 867. Transpose Matrix

    class Solution: def transpose(self, A: List[List[int]]) -> List[List[int]]: return [list(i) for i ...

  8. Swift LeetCode 目录 | Catalog

    请点击页面左上角 -> Fork me on Github 或直接访问本项目Github地址:LeetCode Solution by Swift    说明:题目中含有$符号则为付费题目. 如 ...

  9. leetcode 0211

    目录 ✅ 1217. 玩筹码 描述 解答 c java py ✅ 206. 反转链表 描述 解答 c java py ✅ 922. 按奇偶排序数组 II 描述 解答 c 双指针soldier tddo ...

随机推荐

  1. ATL的GUI程序设计(1)

    from:http://blog.titilima.com/atlgui-1.html 第一章 不能免俗的"Hello, World!" 在这一章里,就像所有的入门级教程一样,我也 ...

  2. 应用层vc实现三种文件监视方法

    http://hi.baidu.com/sadusaga/item/daa0d4b764c6dd76254b09cc http://bbs.csdn.net/topics/280032788 http ...

  3. NR / 5G - Downlink Carrier Waveform

  4. 自定义属性的访问 - Customizing attribute access

    自定义属性的访问 - Customizing attribute access 在 python 中, 下列方法可以实现类实例属性 instance.attribute 的 使用,设置,删除. obj ...

  5. 怎么理解Laravel的核心架构

    使用过larave框架的朋友都知道laravel框架里面除了提供一些基本的功能(如控制器.视图.模型)之外,还有中间件.门面.契约等,这些东西是如何在laravel框架运用起来的呢?今天就和大家详聊一 ...

  6. VFP执行 SQL Server 储存过程示例

    PUBLIC errvalPUBLIC errmsgPUBLIC handleerrval=0errmsg=' ' *Sql Server 连接参数sourcename= 'test'user= 's ...

  7. python os和sys模块使用

    python os和sys模块使用 os.getcwd() 获取当前工作目录,即当前python脚本工作的目录路径 os.chdir("dirname") 改变当前脚本工作目录:相 ...

  8. Firewall 防火墙

    firewalld和iptables的关系: firewalld自身并不具备防火墙的功能,而是和iptables一样需要通过内核的netfilter来实现.也就是说firewalld和iptables ...

  9. MATLAB添加工具箱及无法连接到MathWorks问题

    版本信息:官网下载的MATLAB R2019b 学生版 操作系统:Windows 10 在安装MATLAB时,需要我们自行选择要安装工具箱,如何在已安装MATLAB后添加当初没有选择安装的工具箱呢?第 ...

  10. 第三篇 SpringBoot整合log4j2详解

    源代码:https://pan.baidu.com/s/1d1Lwv1gIvVNltIKVWeEseA 提取码:wff0 SpringBoot整合Log4j2步骤: 1.删除spring-boot-s ...