Question

867. Transpose Matrix

Solution

题目大意:矩阵的转置

思路:定义一个转置后的二维数组,遍历原数组,在赋值时行号列号互换即可

Java实现:

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

867. Transpose Matrix - LeetCode的更多相关文章

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

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

  2. 【LEETCODE】48、867. Transpose Matrix

    package y2019.Algorithm.array; /** * @ProjectName: cutter-point * @Package: y2019.Algorithm.array * ...

  3. 【Leetcode_easy】867. Transpose Matrix

    problem 867. Transpose Matrix solution: class Solution { public: vector<vector<int>> tra ...

  4. 【LeetCode】867. Transpose Matrix 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 先构建数组再遍历实现翻转 日期 题目地址:https ...

  5. LeetCode 867 Transpose Matrix 解题报告

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

  6. [LeetCode&Python] Problem 867. Transpose Matrix

    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

    [题干描述] Given a matrix A, return the transpose of A. The transpose of a matrix is the matrix flipped ...

  8. Leetcode 867. Transpose Matrix

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

  9. [LeetCode] Transpose Matrix 转置矩阵

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

随机推荐

  1. Linux下切换python2和python3

    为什么需要有两个版本的Python Python2和Python3不兼容是每个接触过Python的开发者都知道的事,虽说Python3是未来,但是仍然有很多项目采用Python2开发.Linux的许多 ...

  2. 单总线协议DS1820代码

    单总线协议DS1820代码 一.DS18B20初始化 (1).数据线拉到低电平"0". (2).延时480微妙(该时间的时间范围可以从480到960微妙). (3).数据线拉到高电 ...

  3. js 关于setTimeout和Promise执行顺序问题

    js 关于setTimeout和Promise执行顺序问题 异步 -- Promise和setTimeout 执行顺序   Promise 和 setTimeout 到底谁先执行 定时器的介绍 Jav ...

  4. DRF 视图组件

    目录 DRF 视图组件 视图组件大纲 两个视图基本类 五个扩展类 九个子类视图 视图集 常用视图集父类 魔法类 一览表 DRF中视图的"七十二变" 第一层:基于APIview的五个 ...

  5. CSS简单样式练习(六)

    运行效果: 源代码: 1 <!DOCTYPE html> 2 <html lang="zh"> 3 <head> 4 <meta char ...

  6. 小程序checkbox调整大小(checkbox样式修改)

    .skyCheckbox{ transform: scale(0.7,0.7); -webkit-transform: scale(0.7,0.7); } <label class=" ...

  7. python的数据库编程

    数据库的基础知识 一.数据库的概念 数据库将大量数据按照一定的方式组织并存储起来,是相互关联的数据的集合.数据库中的数据不仅包括描述事物数据的本身,还包括相关数据之间的联系.数据库可以分为关系型数据库 ...

  8. Java连接数据库报错:com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

    解决方案 连接Mysql报错 The last packet sent successfully to the server was 0 milliseconds ago. The driver ha ...

  9. c语言实现双链表的基本操作—增删改查

    //初始化 Node*InitList() { Node*head=(Node*)malloc(sizeof(Node)); if(NULL==head) { printf("内存分配失败! ...

  10. Math内置对象 常用的方法

    属性: Math.Pi 方法: Math.max()   最大值 Math.min()  最小值 Math.ceil()  向上取整 Math.floor() 向下取整 Math.random()   ...