package y2019.Algorithm.array;

/**
* @ProjectName: cutter-point
* @Package: y2019.Algorithm.array
* @ClassName: Transpose
* @Author: xiaof
* @Description: 867. Transpose Matrix
*
* Given a matrix A, return the transpose of A.
* The transpose of a matrix is the matrix flipped over it's main diagonal, switching the row and column indices of the matrix.
*
* Input: [[1,2,3],[4,5,6],[7,8,9]]
* Output: [[1,4,7],[2,5,8],[3,6,9]]
*
* Input: [[1,2,3],[4,5,6]]
* Output: [[1,4],[2,5],[3,6]]
*
* @Date: 2019/7/4 15:44
* @Version: 1.0
*/
public class Transpose { public int[][] solution(int[][] A) { int[][] result = new int[A[0].length][A.length];
for(int column = 0; column < A[0].length; ++column) {
//行
for(int row = 0; row < A.length; ++row) {
result[column][row] = A[row][column];
}
} return result; } }

【LEETCODE】48、867. Transpose Matrix的更多相关文章

  1. 【LEETCODE】45、766. Toeplitz Matrix

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

  2. 【LEETCODE】48、数组分类,简单级别,题目:189,217,219,268,283,414

    package y2019.Algorithm.array; import java.util.Arrays; import java.util.Stack; /** * @ClassName Rot ...

  3. 【LeetCode】9、Palindrome Number(回文数)

    题目等级:Easy 题目描述: Determine whether an integer is a palindrome. An integer is a palindrome when it rea ...

  4. 【LeetCode】 454、四数之和 II

    题目等级:4Sum II(Medium) 题目描述: Given four lists A, B, C, D of integer values, compute how many tuples (i ...

  5. 【LeetCode】18、四数之和

    题目等级:4Sum(Medium) 题目描述: Given an array nums of n integers and an integer target, are there elements ...

  6. 【LeetCode】15、三数之和为0

    题目等级:3Sum(Medium) 题目描述: Given an array nums of n integers, are there elements a, b, c in nums such t ...

  7. 【LeetCode】714、买卖股票的最佳时机含手续费

    Best Time to Buy and Sell Stock with Transaction Fee 题目等级:Medium 题目描述: Your are given an array of in ...

  8. 【LeetCode】48. Rotate Image

    Difficulty:medium  More:[目录]LeetCode Java实现 Description https://leetcode.com/problems/rotate-image/ ...

  9. 【LeetCode】74. Search a 2D Matrix

    Difficulty:medium  More:[目录]LeetCode Java实现 Description Write an efficient algorithm that searches f ...

随机推荐

  1. 堆内存腐败异常(STATUS_HEAP_CORRUPTION---0xC0000374)

    什么是内存腐败 当堆内存位置的内容由于编程行为而被修改,超出了原始程序构造的意图时,计算机程序就会发生内存腐败,也可以叫内存破坏:这被称为违反内存安全.内存腐败的最可能原因是编程错误.当腐败的内存内容 ...

  2. (转)React事件处理函数必须使用bind(this)的原因

    1.JavaScript自身特性说明如果传递一个函数名给一个变量,之后通过函数名()的方式进行调用,在方法内部如果使用this则this的指向会丢失.示例代码:首先我们创建test对象并直接调用方法 ...

  3. ImageView.ScaleType

    前言 对ImageView.ScaleType,学习安卓需掌握.以官方链接:http://android.xsoftlab.net/reference/android/widget/ImageView ...

  4. pip崩了, 解决 ModuleNotFoundError: No module named 'pip'.

    今天 在windows下用pip 安装数据库模块pymysql  把pip 弄崩了,直接出现下面的错误.都是红字, 再输入pip install pymysql  ,会报错ModuleNotFound ...

  5. Java为什么没有指针

    为了摒弃指针带来的风险(当然了,也就放弃了指针带来的效率). 1.C/C++为什么有指针? 这个很简单,程序都是在内存中运行的,只要有内存,就有内存地址,有地址,就必然有指针,只是C++对内存地址的访 ...

  6. 【Excel】定位条件快速将空值替换为指定值

    现有如下表格,表格中存在一些空值,如下图: 目的 将上图的空值全部赋值为100,实现后效果如下: 实现步骤 1.选中数字区域,按CTRL+G 2.点击[定位条件]后,选择[空值]后[确定] 3.在编辑 ...

  7. hotspot编译

    "AA=="1",==", /usr/bin/make -s VERBOSE="-s" LOG_LEVEL="warn" ...

  8. 刷题记录:[CISCN2019 华北赛区 Day1 Web5]CyberPunk

    目录 刷题记录:[CISCN2019 华北赛区 Day1 Web5]CyberPunk 一.知识点 1.伪协议文件读取 2.报错注入 刷题记录:[CISCN2019 华北赛区 Day1 Web5]Cy ...

  9. mark_rabbitMQ

    一.1.6 和1.7的区别 二.63跟65好像有点差异 有些jar包问题 三.预取策略 https://blog.csdn.net/hry2015/article/details/79078312 四 ...

  10. pgsql 聚合函数array_to_string,ARRAY_AGG

    array_to_string--将sql中的数组转为字符串 ARRAY_AGG--将sql中的数据转为数组处理 以下给大家一个简单的例子即可体会: 1.需求     2.数据库中原数据   1.pn ...