【LEETCODE】48、867. Transpose Matrix
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的更多相关文章
- 【LEETCODE】45、766. Toeplitz Matrix
package y2019.Algorithm.array; /** * @ProjectName: cutter-point * @Package: y2019.Algorithm.array * ...
- 【LEETCODE】48、数组分类,简单级别,题目:189,217,219,268,283,414
package y2019.Algorithm.array; import java.util.Arrays; import java.util.Stack; /** * @ClassName Rot ...
- 【LeetCode】9、Palindrome Number(回文数)
题目等级:Easy 题目描述: Determine whether an integer is a palindrome. An integer is a palindrome when it rea ...
- 【LeetCode】 454、四数之和 II
题目等级:4Sum II(Medium) 题目描述: Given four lists A, B, C, D of integer values, compute how many tuples (i ...
- 【LeetCode】18、四数之和
题目等级:4Sum(Medium) 题目描述: Given an array nums of n integers and an integer target, are there elements ...
- 【LeetCode】15、三数之和为0
题目等级:3Sum(Medium) 题目描述: Given an array nums of n integers, are there elements a, b, c in nums such t ...
- 【LeetCode】714、买卖股票的最佳时机含手续费
Best Time to Buy and Sell Stock with Transaction Fee 题目等级:Medium 题目描述: Your are given an array of in ...
- 【LeetCode】48. Rotate Image
Difficulty:medium More:[目录]LeetCode Java实现 Description https://leetcode.com/problems/rotate-image/ ...
- 【LeetCode】74. Search a 2D Matrix
Difficulty:medium More:[目录]LeetCode Java实现 Description Write an efficient algorithm that searches f ...
随机推荐
- hibernate的持久化类、主键生成策略
一.hibernate的持久化类 1.什么是持久化类: 持久化:将数据存储到关系型数据库. 持久化类:与数据库中的数据表建立了某种关系的java类.(持久化类=javabean+映射配置文件) 2.持 ...
- bootstrap轮播图组件
一.轮播图组件模板(官方文档) <div id="carousel-example-generic" class="carousel slide" dat ...
- 数据分析师(Data Analyst),数据工程师(Data Engineer),数据科学家(Data Scientist)的区别
数据分析师(Data Analyst):负责从数据中提取出有用的信息,以帮助公司形成业务决策.工作内容包括:对数据进行提取,清洗,分析(用描述统计量,趋势分析,多维度分析,假设检验等统计常用方法对数据 ...
- linux命令之------Linux文件系统具体目录
Linux文件系统具体目录 (1)/ Linux文件系统的入口,也是处于最高一级的目录 (2)/bin 系统所需要的那些命令处于此目录,比如Is,cp,mkdir等命令:功能和/usr/bin类似 ...
- 利用window.open如何绕过浏览器拦截机制
在浏览器的安全机制里,非用户触发的window.open方法是会被拦截的,例如: var btn = $('#btn'); btn.click(function () { // 算做用户触发,所以不会 ...
- 笔记 - 数据结构 - 区间第k大
Codeforces Round #602 (Div. 2, based on Technocup 2020 Elimination Round 3) D2 - Optimal Subsequence ...
- #C++初学记录(set进阶#acm cf 190802 B. Subsegments)
B. Subsegments#set进阶 Programmer Sasha has recently begun to study data structures. His coach Stas to ...
- shell中$(( ))、$( )、``与${ }的区别
转 :shell $(( )).$( ).``与${ }的区别 $( )与` `(反引号)命令替换 在bash中,$( )与` `(反引号)都是用来作命令替换的.命令替换与变量替换差不多,都是用来重组 ...
- 第06组 Alpha冲刺(2/4)
队名:福大帮 组长博客链接:https://www.cnblogs.com/mhq-mhq/p/11885037.html 作业博客 :https://edu.cnblogs.com/campus/f ...
- flask 开发用户登录注册功能
flask 开发用户登录注册功能 flask开发过程议案需要四个模块:html页面模板.form表单.db数据库操作.app视图函数 1.主程序 # app.py # Auther: hhh5460 ...