[LeetCode] [C] 48. Rotate Image
来源:互联网 发布:js隐藏显示tr 编辑:程序博客网 时间:2024/06/05 11:52
Looking at the input matrix and the output matrix,
we can easily find that it rotates 90° clockwise.
And I implement that by rotating every "circle" of it.
First I rotate the outmost circle,
then to the inside,
still to the inside,
until there's no more circle.
The Runtime of the program is 3 ms.
The length of the code is 509 Bytes.
void rotate(int** matrix, int matrixRowSize, int matrixColSize) { int i,j,tmp; for (j=0; j<matrixRowSize/2; j++) { for (i=0; i<matrixRowSize-2*j-1; i++) { tmp=matrix[j][i+j]; matrix[j][i+j]=matrix[matrixRowSize-i-j-1][j]; matrix[matrixRowSize-i-j-1][j]=matrix[matrixRowSize-j-1][matrixColSize-i-j-1]; matrix[matrixRowSize-j-1][matrixColSize-i-j-1]=matrix[i+j][matrixColSize-j-1]; matrix[i+j][matrixColSize-j-1]=tmp; } }}
阅读全文
0 0
- 【C++】【LeetCode】48. Rotate Image
- [LeetCode] [C] 48. Rotate Image
- [LeetCode]48.Rotate Image
- LeetCode 48. Rotate Image
- LeetCode 48.Rotate Image
- LeetCode --- 48. Rotate Image
- [Leetcode] 48. Rotate Image
- [leetcode] 48. Rotate Image
- Leetcode 48. Rotate Image
- 48. Rotate Image LeetCode
- [LeetCode]48. Rotate Image
- leetcode 48. Rotate Image
- Leetcode 48. Rotate Image
- LeetCode 48. Rotate Image
- LeetCode *** 48. Rotate Image
- [LeetCode]48. Rotate Image
- LeetCode 48. Rotate Image
- LeetCode-48.Rotate Image
- 普元 EOS Platform Governor HTTP接入不拦截Url配置规则
- Cocoscreator-初试creator
- iOS自定义游标滑尺
- docker service create 报:No such image:错误解决办法
- Ubuntu16.04 搭建svn
- [LeetCode] [C] 48. Rotate Image
- 微信公众号消息增加跳转链接
- 重新开始写博客 时间待定
- 完全卸载oracle11g步骤
- pyqt配置记录-关于eirc6的QT设计大师无法启动的问题
- Java多线程总结之由synchronized说开去
- Wifi源码学习之wifi连接
- 121. Best Time to Buy and Sell Stock 最佳买卖股票时间
- 一些从源码编译 pytorch的时候的问题