LeetCode Spiral Matrix
class Solution {
public:
vector<int> spiralOrder(vector<vector<int> > &matrix) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
int m,n;
int cir;
int i,j;
vector<int> re;
if(matrix.size()==)
return re; m=matrix.size();
n=matrix[].size(); cir=min(m,n);
cir=(cir+)/;
for(i=;i<cir;i++)
{
for(j=i;j<i+n-(i)*;j++)
re.push_back(matrix[i][j]); for(j=i+;j<i++m-(i+)*;j++)
re.push_back(matrix[j][i+n-(i)*-]); if(i++m-(i+)*!=i)
for(j=i+n-(i)*-;j>=i;j--)
re.push_back(matrix[i++m-(i+)*][j]); if(i+n-(i)*-!=i)
for(j=i++m-(i+)*-;j>i;j--)
re.push_back(matrix[j][i]);
}
return re; }
};
LeetCode Spiral Matrix的更多相关文章
- LeetCode: Spiral Matrix II 解题报告-三种方法解决旋转矩阵问题
Spiral Matrix IIGiven an integer n, generate a square matrix filled with elements from 1 to n2 in sp ...
- [LeetCode] Spiral Matrix II 螺旋矩阵之二
Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. For ...
- [LeetCode] Spiral Matrix 螺旋矩阵
Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral or ...
- LeetCode:Spiral Matrix I II
Spiral Matrix Given a matrix of m x n elements (m rows, n columns), return all elements of the matri ...
- [LeetCode]Spiral Matrix 54
54.Spiral Matrix Given a matrix of m x n elements (m rows, n columns), return all elements of the ma ...
- LeetCode: Spiral Matrix 解题报告
Spiral MatrixGiven a matrix of m x n elements (m rows, n columns), return all elements of the matrix ...
- [Leetcode] spiral matrix ii 螺旋矩阵
Given an integer n, generate a square matrix filled with elements from 1 to n 2 in spiral order. For ...
- LeetCode——Spiral Matrix
Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral or ...
- [leetcode]Spiral Matrix II @ Python
原题地址:https://oj.leetcode.com/problems/spiral-matrix-ii/ 题意: Given an integer n, generate a square ma ...
- [leetcode]Spiral Matrix @ Python
原题地址:https://oj.leetcode.com/problems/spiral-matrix/ 题意: Given a matrix of m x n elements (m rows, n ...
随机推荐
- js显示隐藏
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- 关于打印机能PING通但是无法打开\\地址的问题
首先PING地址,看是否能否PING通,如果不通,代表网络不通不能共享, 如果能PING通,但是无法打开\\地址,那么就就检查这几个地方: 1 防火墙是否关闭 2 print splooer 打印 ...
- 搭建一个简单的svn服务器
cenos 6.5,svnserver 1.6.11 默认可能已经安装,没有的话就: yum install svn -ysvnserver --version 创建一个svn仓库: svnadmin ...
- 20161127-emmagee
Android 自动化测试 Emmagee Emmagee 是一个性能测试小工具 用来监控指定被测应用在使用过程中占用机器的CPU, 内存,流量资源的性能小工具 阅读目录 Emmagee 介绍 Emm ...
- 动态规划(DP)
一.基本概念 动态规划过程是:每次决策依赖于当前状态,又随即引起状态的转移.一个决策序列就是在变化的状态中产生出来的,所以,这种多阶段最优化决策解决问题的过程就称为动态规划. 二.基本思想与策略 基本 ...
- Android Studio 2.0使用指南
一.下载界面.[无激活码 无序列码 无毒请放心使用][需将JAVA程序升级到1.8] 网址:http://www.android-studio.org/index.php/download/andro ...
- Oracle(修改表结构和约束)
目标: 1.添加和修改列 2.添加,enable,disable,或者remove约束 3.删除表 4.删除表中所有数据并回到表定义的初始状态(截断表) 5.修改对象的名字 6.给对象添加注释,从数据 ...
- Fiddler 4 抓包
Fiddler 4 Tools –> Fiddler Options HTTPS -> 勾选"CaptureHTTPS CONNECTs",同时勾选"Decr ...
- Kinect外包团队(长年承接微软Kinect体感项目外包,有大型Kinect案例)
承接Kinect体感企业项目.游戏项目外包 北京公司.专业团队,成员为专业WPF产品公司一线开发人员,有大型产品开发经验: 提供优质的售后服务,保证产品质量,轻量级产品可以提供规范清晰的源代码,有业务 ...
- 推荐相关学习 & 典型算法、典型特征、典型推荐系统框架
总的来说,信息爆炸,产生了信息过载.解决的方法主要有两类:检索和推荐.检索是主动的有目的的.意图明确,推荐是非主动的.意图不明确. 推荐方面最经典的,就是协同过滤推荐了.我博客这里有两篇,一篇偏理论, ...