【LEETCODE】48、867. Transpose Matrix
2024-10-21 09:40:42
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; } }
最新文章
- MySQL数据库安装与配置详解
- 关于ecshop的那些故事
- SQL语句 - 基本查询
- 56个睿智帅气貌美的CTO大牛陪你叨逼叨
- JAVA 对象的转型
- 点击后弧形展开的炫酷菜单--第三方开源-- CircularFloatingActionMenu(一)
- 使用Office2007向cnblogs.com发布文章
- IOS 通过button获取cell
- 1170: 非常男女(XCOJ 前缀和)
- R与数据分析旧笔记(十六) 基于密度的方法:DBSCAN
- Bootstrap学习(一):Bootstrap简介
- c# WebApi之身份验证:Basic基础认证
- Linux巩固记录(4) 运行hadoop 2.7.4自带demo程序验证环境
- C#访问SQLServer数据库访问帮助类
- fusionjs 学习一 基本试用
- [转] gitlab 的 CI/CD 配置管理
- HDU 4585 Shaolin(水题,STL)
- ANE-IOS与AS的互通
- es6笔记4^_^function
- python_day4学习笔记