Java for LeetCode 048 Rotate Image
You are given an n x n 2D matrix representing an image.
Rotate the image by 90 degrees (clockwise).
Follow up:
Could you do this in-place?
解题思路:
找规律即可,JAVA实现如下:
static public void rotate(int[][] matrix) {
	int[][] matrixArray=new int[matrix.length][matrix[0].length];
	for(int i=0;i<matrix.length;i++)
		System.arraycopy(matrix[i], 0, matrixArray[i], 0, matrix[i].length);
    for(int i=0;i<matrix.length;i++)
    	for(int j=0;j<matrix.length;j++)
    		matrix[i][j]=matrixArray[matrix.length-j-1][i];
    }
Java for LeetCode 048 Rotate Image的更多相关文章
- [Leetcode][048] Rotate Image 略详细 (Java)
		
题目在这里 https://leetcode.com/problems/rotate-image/ [个人分析] 这个题目,我觉得就是考察基本功.考察细心的,算法方面没有太多东西,但是对于坐标的使用有 ...
 - Java for LeetCode 189 Rotate Array
		
Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array ...
 - Java for LeetCode 061 Rotate List
		
Given a list, rotate the list to the right by k places, where k is non-negative. For example: Given ...
 - LeetCode 048 Rotate Image
		
题目要求:Rotate Image You are given an n x n 2D matrix representing an image. Rotate the image by 90 deg ...
 - [LeetCode] 61. Rotate List 旋转链表
		
Given a linked list, rotate the list to the right by k places, where k is non-negative. Example 1: I ...
 - Java for LeetCode 216 Combination Sum III
		
Find all possible combinations of k numbers that add up to a number n, given that only numbers from ...
 - Java for LeetCode 214 Shortest Palindrome
		
Given a string S, you are allowed to convert it to a palindrome by adding characters in front of it. ...
 - Java for LeetCode 212 Word Search II
		
Given a 2D board and a list of words from the dictionary, find all words in the board. Each word mus ...
 - Java for LeetCode 211 Add and Search Word - Data structure design
		
Design a data structure that supports the following two operations: void addWord(word)bool search(wo ...
 
随机推荐
- 【CodeForces 604B】F - 一般水的题1-More Cowbe
			
Description Kevin Sun wants to move his precious collection of n cowbells from Naperthrill to Exeter ...
 - oracle 用Navicat创建的表的查询问题
			
navicat可视化创建了表,可是就是不能查到!这个为什么呢? select * from user; 我们如果给user加上双引号才能查到 select * from "user" ...
 - OpenJudge 7624 山区建小学
			
在openjudge似乎无法凭题号搜到题...? 总时间限制: 1000ms 内存限制: 65536kB 描述 政府在某山区修建了一条道路,恰好穿越总共m个村庄的每个村庄一次,没有回路或交叉,任 ...
 - Mysql 学习-索引的设计原则
			
索引的设计不合理或者缺少索引都会对数据库和应用程序的性能造成障碍.高效的索引对获的良好性能非常重要.设计索引是,应该考虑一下准则: (1)索引并非语讹夺越好,若一个表中有大量索引,不仅占用磁盘空间,而 ...
 - HD1205吃糖果(鸽巢、抽屉原理)
			
吃糖果 Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submiss ...
 - 异步http框架简介&实现原理
			
1 )说明: Android开源代码:www.github.com 模拟一个异步http请求说明
 - 详细解读Jquery各Ajax函数:$.get(),$.post(),$.ajax(),$.getJSON()
			
一,$.get(url,[data],[callback]) 说明:url为请求地址,data为请求数据的列表(是可选的,也可以将要传的参数写在url里面),callback为请求成功后的回调函数,该 ...
 - 周期串(Periodic Strings,UVa455)
			
解题思路: 对一个字符串求其最小周期长度,那么,最小周期长度必定是字符串长度的约数,即最小周期长度必定能被字符串长度整除 其次,对于最小周期字符串,每位都能对应其后周期字串的每一位, 即 ABC A ...
 - C++_Eigen函数库用法笔记——Matrix and Vector Arithmetic
			
Addition and subtraction Scalar multiplication and division Transposition Matrix-matrix and matrix-v ...
 - 怎样把excel一列分成多列
			
1,选定要分列的列. 2,点击“数据”-“分列”. 3,在选项栏中设置如图 4,选择分隔符 4,看,分开了吧!