LeetCode刷题之面试题29. 顺时针打印矩阵

捷联惯导总结--初始对准,位置标定,INS姿态更新,GPS/INS组合 惯导及组合导航回顾  2018.09.16 今天和17系的同学一起把惯导的流程捋了一遍,为了加深自己的记忆,这里在前面把心得大致列出来。 我们这里只考虑捷联式惯导及松组合 首先拿到惯性传感器(加速度计和陀螺仪)需要对其进行标定,是为了求出零偏,比例因子,交轴耦合这些误差。这些误差有的虽然在出厂时会给出,但是考虑到实际环境不同,还是要做标定。一般采用的是六位置旋转法,针对加速度计和陀螺仪同时... 阅读详情

LeetCode刷题之面试题29. 顺时针打印矩阵

我不知道将去向何方,但我已在路上!
时光匆匆,虽未曾谋面,却相遇于斯,实在是莫大的缘分,感谢您的到访 !
  • 题目:
    输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字。
  • 示例:
示例 1 :
输入:matrix = [[1,2,3],[4,5,6],[7,8,9]]
输出:[1,2,3,6,9,8,7,4,5]
示例 2 :
输入:matrix = [[1,2,3,4],[5,6,7,8],[9,10,11,12]]
输出:[1,2,3,4,8,12,11,10,9,5,6,7]
  • 限制:
    • 0 <= matrix.length <= 100
    • 0 <= matrix[i].length <= 100
  • 代码:
class Solution:
    def spiralOrder(self, matrix: List[List[int]]) -> List[int]:
        if matrix == []: return []
        left, right, up, down, result = 0, len(matrix[0])-1, 0, len(matrix)-1, []
        while 1:
            for i in range(left,right+1): result.append(matrix[up][i])
            up += 1
            if up > down: break
            for i in range(up,down+1): result.append(matrix[i][right])
            right -= 1
            if left > right: break
            for i in range(right,left-1,-1): result.append(matrix[down][i])
            down -= 1
            if up > down: break
            for i in range(down,up-1,-1): result.append(matrix[i][left])
            left += 1
            if left > right: break
        return result
# 执行用时 :52 ms, 在所有 Python3 提交中击败了57.55%的用户
# 内存消耗 :14 MB, 在所有 Python3 提交中击败了100.00%的用户
  • 算法说明:
    首先求出矩阵的边缘left, right, up, down;
    第一个循环从左到右进行输出矩阵元素,循环之后将上边缘的值+1,如果上边缘的值大于下边缘,退出while,返回result;
    第二个循环从上到下进行输出矩阵元素,循环之后将右边缘的值-1,如果左边缘的值大于右边缘,退出while,返回result;
    第三个循环从右到左进行输出矩阵元素,循环之后将下边缘的值-1,如果上边缘的值大于下边缘,退出while,返回result;
    第一个循环从下到上进行输出矩阵元素,循环之后将左边缘的值+1,如果左边缘的值大于右边缘,退出while,返回result;
    如果while循环没有退出,继续循环,最后返回result。
【数据清洗】数据清洗流程及经验 预处理阶段 预处理阶段主要做两件事情: 一是将数据导入处理工具。 二是看数据。包含两个部分:一是看元数据,包括字段解释、数据来源、代码表等等一切描述数据的信息;二是抽取一部分数据,对数据本身有一个直观的了解,并且初步发现一些问题,为之后的处理做准备。 第一步:缺失值清洗 四个步骤: 1、确定缺失值范围:对每个字段都计算其缺失值比例,然后按照缺失比例和字段重要性,分别制定策略。 2、去除不需要的... 阅读详情

相关推荐

开源数显表

开源数显表,广泛应用于车床、铣床、磨床、镗床、火花机、线切割等。市面上此类液晶数显表多数都是基于此项目。 一、基本配置 硬件 主控:STM32F407VGT6 LCD:群创AT070TN92 显示驱动:RA8875 光栅尺:3 x 输入(X/Y/Z) 串口:1 x MAX3232 继电器:2 x 输出 存储:AT24C64 模拟输入:LM324C 电源:AC 220V 软件 工程版本:Keil 5 STM32库:V1.4.0 图形界面:uCGUI 多语言支持:中文、英文 二、项目文

m0_70934529的博客 443

【LeetCode】剑指 Offer 29. 顺时针打印矩阵

剑指 Offer 29. 顺时针打印矩阵

2022年毕业的萌新程序猿,输出一下自己的学习内容~ 430

保姆级教程:用QSTEM和DrProbe搞定你的第一张STEM模拟图(附Fe3O4实例文件)

本文提供了一份详细的STEM模拟图像生成教程,涵盖从晶体结构获取到最终图像模拟的全过程。通过QSTEM和DrProbe软件的操作指南,帮助材料科学研究者快速掌握STEM模拟技术,特别适合初学者。教程包含Fe3O4实例文件,详细解析参数设置、计算优化和结果分析等关键步骤。

weixin_33730836的博客 539

Leetcode刷题笔记——剑指 Offer 29. 顺时针打印矩阵(简单)

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 Leetcode刷题笔记——剑指 Offer 29. 顺时针打印矩阵(简单)题目描述方法一:模拟复杂度分析C++代码方法二:按层模拟复杂度分析C++代码方法三C++代码参考链接 题目描述 输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字。 示例 1: 输入:matrix = [[1,2,3],[4,5,6],[7,8,9]] 输出:[1,2,3,6,9,8,7,4,5] 限制: 0 <= matrix.length &l

weixin_39739042的博客 488

freeswitch系列二 kamailio 5.0安装及实现kamailio集成freeswitch

kamailio是个纯粹的SIP服务器。本文介绍先如何在debian8下安装debian5.0,然后详细介绍如何实现使用kamailio做freeswitch均衡负载。kamailio同时实现做为代理服务器、注册服务器、重定向服务器。

不积跬步无以至千里; 不积小流无以成江海 1万+

双轴按键摇杆模块原理与嵌入式驱动实战

双轴按键摇杆是一种融合模拟量(X/Y轴)与数字量(Z轴按键)的复合型人机交互传感器,其本质基于电位器分压原理与机械开关通断特性。通过ADC采集连续电压信号并结合数字IO检测按键状态,可实现高鲁棒性的二维运动感知与触发控制。该方案技术门槛低、成本可控、兼容性强,广泛应用于智能小车、DIY游戏手柄、工业HMI及教育开发板等嵌入式场景。文中深入解析电位器线性度、KEY引脚开漏特性、ADC参考电压稳定性及软件消抖状态机等关键工程要素,为基于Arduino、STM32或ESP32平台的快速集成提供可复用的技术路径。

weixin_30995917的博客 96

顺时针打印矩阵

题目 输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字。 示例 1: 输入:matrix = [[1,2,3],[4,5,6],[7,8,9]] 输出:[1,2,3,6,9,8,7,4,5] 示例 2: 输入:matrix = [[1,2,3,4],[5,6,7,8],[9,10,11,12]] 输出:[1,2,3,4,8,12,11,10,9,5,6,7] 限制: 0 <= matrix.length <= 100 0 <= matrix[i].length

学习印记 Learning imprint 602

AIDD机器学习深度学习药物发现与设计教程总结

AIDD(AI Drug Discovery & Design):是近年来非常火热的技术应用,且已经介入到新药设计到研发的大部分环节当中,为新药发现与开发带来了极大的助力。倾向于机器对数据库信息的自我学习,可以对数据进行提取和学习,一定程度上避免了化合物设计过程中的试错路径,同时还会带来很多全新的结构,为药物发现打破常规的结构壁垒。覆盖了机器学习和深度学习,能与新药研发相结合并实质性的应用到靶点预测、高通量筛选、药物设计、药物的ADMET性质预测等;且算力方面,由早期应用于药物发现领域的决策树、随机

wutianlin0723的博客 6828

leetcode题解-顺时针打印矩阵

思路 判断是否是空数组 顺时针打印数组 可以按照字面意思 从外向里进行圈层遍历 。 判断圈数 可以遍历的圈数是根据短边来判断的 这里有三种情况 圈数为偶数的情况 圈数为奇数的情况 且长>=宽 圈数为奇数的情况 且长<宽 当为偶数时 直接按照下面第一张图 将一圈分为四个部分 依次从顶点遍历即可 当为奇数时 会产生行/列的冗余 最后只需要把冗余部分 依次push进数组就可以了 代码 var spiralOrder = function(matrix) { if (matrix.l

magic-zhu 259

曲线生成 | 图解B样条曲线生成原理(附ROS C++/Python/Matlab仿真)

本文分插值和近似两个方面介绍B样条曲线的控制点计算,以及曲线生成原理,并给出ROS C++/Python/Matlab三种实现加深理解

FRIGIDWINTER的博客 6619

UG NX二次开发(Python)-API函数介绍与应用实例(三)-UFLayer类操作

采用Python语言进行UG NX二次开发的帮助材料很少,采用录制的方法是一种比较容易实现的方式,但是使用UFun函数更容易上手,我们以后将逐渐的将Python-UFun的功能写进博客中,以便于有需要的人采纳和研究。本博客是为了入门需要,采用简单的创建长方体的功能来讲一下怎么使用Python语言开发。我们今天以移动长方体到某一个图层为例,讲一下UFLayer类中部分函数的使用。另外,我们长期提供UG NX二次开发的功能开发和咨询服务,有疑问可以私信博主或者在评论区讨论。

GimiGimmy 718

Leetcode顺时针打印矩阵

Leetcode 54. Spiral Matrix Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. Example 1: Input: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] Outpu...

heheSakura的博客 479

在RV1126上实现人脸识别----MobileFaceNet转成rknn模型

目录 1.模型下载 2 转成rknn模型并推理 3 查看网络模型 1.模型下载 首先下载MobileFaceNet的模型,github下载地址为:https://github.com/sirius-ai/MobileFaceNet_TF/tree/master/arch/pretrained_model/ 2 转成rknn模型并推理 import numpy as np import cv2 from rknn.api import RKNN if __name__ == '__..

C/C++、嵌入式开发、深度学习算法、模型部署与推理优化 3541

leetcode刷题-面试题29. 顺时针打印矩阵

面试题29. 顺时针打印矩阵 输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字。 示例 1: 输入:matrix = [[1,2,3],[4,5,6],[7,8,9]] 输出:[1,2,3,6,9,8,7,4,5] 示例 2: 输入:matrix = [[1,2,3,4],[5,6,7,8],[9,10,11,12]] 输出:[1,2,3,4,8,12,11,10,9,5,6,7] 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/shu

weixin_42846216的博客 297

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

Leetcode刷题:剑指offer【面试题29 顺时针打印矩阵】

文章目录思路 1:遍历思路 2:旋转矩阵 【面试题29 顺时针打印矩阵】 难度: 简单 输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字。 Leetcode题目对应位置: 面试题29:顺时针打印矩阵 思路 1:遍历 设置 4 个边界:top,bottom,left,right,用以限制当前遍历的最大范围。遍历顺序按照:从左到右,从上到下,从右到左,从下到上的顺序。 时间复杂度:O(mn),m 和 n 分别为矩阵的行数和列数 空间复杂度:O(1),存储新的遍历顺序 class Solution:

学习 & 分享 ~ 351

vb 6.0并口开发操作实例

vb6并口开发,简体中文,试例内有inpout32.dll动态链接库

LeetCode 面试题29. 顺时针打印矩阵

我的LeetCode:https://leetcode-cn.com/u/ituring/ 我的LeetCode刷题源码[GitHub]:https://github.com/izhoujie/Algorithmcii LeetCode 面试题29. 顺时针打印矩阵 与以下题目相同 前往:LeetCode 54. 螺旋矩阵 ...

iTuring_Zhou的专栏 128

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Leetcode刷题之旅(每日一题)--面试题29. 顺时针打印矩阵

题目描述 代码: class Solution { public static void main(String[] args) { int[][] a={{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16}}; new Solution().spiralOrder(a); } public int[] spiralOrder(int[][] matrix) { if (matrix.length=

weixin_45129136的博客 170

Leetcode面试题29. 顺时针打印矩阵[Easy] -JAVA

面试题29. 顺时针打印矩阵 https://leetcode-cn.com/problems/shun-shi-zhen-da-yin-ju-zhen-lcof/ 输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字。 示例 1: 输入:matrix = [[1,2,3],[4,5,6],[7,8,9]] 输出:[1,2,3,6,9,8,7,4,5] 示例 2: 输入:matrix = [[1,2,3,4],[5,6,7,8],[9,10,11,12]] 输出:[1,2,3,4,8,12,11,1

小小柯 223

力扣 面试题29. 顺时针打印矩阵(简单难度)

力扣 面试题29. 顺时针打印矩阵(简单难度) 题目: 输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字。 示例 1: 输入:matrix = [[1,2,3],[4,5,6],[7,8,9]] 输出:[1,2,3,6,9,8,7,4,5] 示例 2: 输入:matrix = [[1,2,3,4],[5,6,7,8],[9,10,11,12]] 输出:[1,2,3,4,8,12,11,10,9,5,6,7] 说说这题的思路,我先定义了当前坐标,用(x,y)表示,然后定义上左下右四个边界值。模拟取

weixin_43838406的博客 379

leetcode 面试题29. 顺时针打印矩阵

leetcode 面试题29. 顺时针打印矩阵 题目详情 题目链接 输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字。 示例 1: 输入:matrix = [[1,2,3],[4,5,6],[7,8,9]] 输出:[1,2,3,6,9,8,7,4,5] 示例 2: 输入:matrix = [[1,2,3,4],[5,6,7,8],[9,10,11,12]] 输出:[1,2,3,4,8,12,11,10,9,5,6,7] 限制: 0 <= matrix.length <= 10

qq_33789406的博客 232

leetcode--顺时针打印矩阵

 题目来自LeetCode,链接:面试题29. 顺时针打印矩阵。具体描述为:输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字。  示例1: 输入:matrix = [[1,2,3],[4,5,6],[7,8,9]] 输出:[1,2,3,6,9,8,7,4,5]  示例2: 输入:matrix = [[1,2,3,4],[5,6,7,8],[9,10,11,12]] 输出:[1,2,3,4,8,12,11,10,9,5,6,7]  蛮经典的题目,记得本科那会参加一个笔试就做过这道题。做法也比较

JR_Chan的博客 524

LeetCode-面试题29、顺时针打印矩阵-简单

LeetCode-面试题29、顺时针打印矩阵-简单 输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字。 示例 1: 输入:matrix = [[1,2,3],[4,5,6],[7,8,9]] 输出:[1,2,3,6,9,8,7,4,5] 示例 2: 输入:matrix =[[1,2,3,4],[5,6,7,8],[9,10,11,12]] 输出:[1,2,3,4,8,12,11,10,9,5,6,7] 限制: 0 <= matrix.length <= 100 0 .

clover_my的博客 276

【Python】【难度:简单】Leetcode 面试题29. 顺时针打印矩阵【完】

输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字。 示例 1: 输入:matrix = [[1,2,3],[4,5,6],[7,8,9]] 输出:[1,2,3,6,9,8,7,4,5] 示例 2: 输入:matrix =[[1,2,3,4],[5,6,7,8],[9,10,11,12]] 输出:[1,2,3,4,8,12,11,10,9,5,6,7] 限制: 0 <= matrix.length <= 100 0 <= matrix[i].length&...

thomashhs12的博客 376

LeetCode刷题日记 剑指 Offer 29. 顺时针打印矩阵

之前几天在看吴恩达,LeetCode停了几天,今天重新开始,希望之后每天能抽出时间写几道。 这道题目是剑指offer上的第29题,顺势正打印矩阵。题目给出一个由数组构成的矩阵,要求顺时针顺序从里到外打印出每一个数字,代码如下: class Solution { public: vector<int> spiralOrder(vector<vector<int>>& matrix) { if (matrix.size() == 0 ||

AlexNbZou的博客 176

每日一题:Leetcode 面试题 29.顺时针打印矩阵

题目描述: 输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字。 示例 1: 输入:matrix = [[1,2,3],[4,5,6],[7,8,9]] 输出:[1,2,3,6,9,8,7,4,5] 示例 2: 输入:matrix = [[1,2,3,4],[5,6,7,8],[9,10,11,12]] 输出:[1,2,3,4,8,12,11,10,9,5,6,7] 限制: 0 <...

qq_44584356的博客 503

算法(LeetCode_面试题29_顺时针打印矩阵)

算法 概:今日份的LeetCode每日一题,这道题被判为简单难度,看题直接出思路的那种,但是,我还是交了很多很多次,错了好些个地方,主要自己写代码太不注意细节,所以记录一手。 来源:力扣(LeetCode) 链接:顺时针打印矩阵 题目 输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字。 示例 示例 1: 输入:matrix = [[1,2,3],[4,5,6],[7,8,9]] 输出:[1,2,3,6,9,8,7,4,5] 示例 2: 输入:matrix = [[1,2,3,4],[5,6,7,

诡白丷的博客 304
上一篇: LeetCode刷题之LCP 06. 拿硬币
下一篇: LeetCode刷题之970.强整数
O_胡萝卜_O
博客等级 码龄11年 70粉丝 382原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

O_胡萝卜_O

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值