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. 洛谷 P1821 [USACO07FEB]银牛派对Silver Cow Party 题解

    P1821 [USACO07FEB]银牛派对Silver Cow Party 题目描述 One cow from each of N farms (1 ≤ N ≤ 1000) conveniently ...

  2. mysql 字段拼接

    mysql> select concat(name,"**",id) as test from test; +----------------+ | test | +---- ...

  3. JavaScript中class类的介绍

    class的概念 一.我们为什么要用到class类? 因为通过class类来创建对象,使得开发者不必写重复的代码,以达到代码复用的目的.它基于的逻辑是,两个或多个对象的结构功能类似,可以抽象出一个模板 ...

  4. Koa 操作 Mongodb 数据库

    node-mongodb-native的介绍 使用基于官方的 node-mongodb-native 驱动,封装一个更小.更快.更灵活的 DB 模块, 让我们用 nodejs 操作 Mongodb 数 ...

  5. Jmeter常用插件:梯度加压/插件管理器

    一.Jmeter梯度加压的 jar:Stepping Thread Group,下载方法如下: 1.访问网网站:https://jmeter-plugins.org/downloads/old/ 2. ...

  6. kafka集群部署以及单机部署

      kafka单机部署 一.环境准备 当前环境:centos7.3一台软件版本:kafka_2.12部署目录:/usr/local/kafka启动端口:9092配置文件:/usr/local/kafk ...

  7. 【Js】单页面多个倒计时问题

    代码: <!DOCTYPE html> <html> <head> <title>多个timeout</title> <script ...

  8. 【docker】 yaml.scanner.ScannerError: mapping values are not allowed here in "./docker-compose.yml", line 60, column 35

    在启动docker-compose 时候 报错了 命令: docker-compose up -d && docker-compose logs -f 错误代码: 解决 出现这个错误的 ...

  9. [LeetCode] 276. Paint Fence 粉刷篱笆

    There is a fence with n posts, each post can be painted with one of the k colors. You have to paint ...

  10. [LeetCode] 271. Encode and Decode Strings 加码解码字符串

    Design an algorithm to encode a list of strings to a string. The encoded string is then sent over th ...