当前位置: 首页 > news >正文

手工制作灯笼视频教程seo推广软件下载

手工制作灯笼视频教程,seo推广软件下载,网站排名软件网址,连锁店网站建设54. 螺旋矩阵 - 力扣(LeetCode) 给你一个 m 行 n 列的矩阵 matrix ,请按照 顺时针螺旋顺序 ,返回矩阵中的所有元素。 示例 1: 输入:matrix [[1,2,3],[4,5,6],[7,8,9]] 输出:[1,2,3,6,9,8,7,4,5…

54. 螺旋矩阵 - 力扣(LeetCode)

给你一个 m 行 n 列的矩阵 matrix ,请按照 顺时针螺旋顺序 ,返回矩阵中的所有元素。

示例 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]

提示:

  • m == matrix.length
  • n == matrix[i].length
  • 1 <= m, n <= 10
  • -100 <= matrix[i][j] <= 100

class Solution {int x=0,y=0;public List<Integer> spiralOrder(int[][] matrix) {ArrayList<Integer> arr = new ArrayList();int row = matrix.length;int col = matrix[0].length;System.out.print(row);int total = row * col - 1;int count = 0;arr.add(matrix[0][0]);for(int i = 0 ;count < total; ++i) {y+=1;while(y<(col-i))   { arr.add(matrix[x][y]);y++;count++;}if(count>=total) break;y-=1;x+=1;while(x<(row-i))  {  arr.add(matrix[x][y]);x++;count++;}if(count>=total) break;x-=1;y-=1;while(y>=i)     {    arr.add(matrix[x][y]);y--;count++;}if(count>=total) break;y+=1;x-=1;while(x>i)      {   arr.add(matrix[x][y]);x--;count++;}if(count>=total) break;x+=1;}return arr;}
}

        这是一道中等题,但是实际难度来算的话,博主觉得是达不到中等题的程度的,所以大家刷题的时候,不要被题目标记的难度所吓倒。、

         这道题其实也是模拟就可以解决。主要的问题在于边界的控制。

        按照这个例子来说,可以使用x,y来表示行和列,用arrlist来存储最后的答案。之后就是循环的问题了,循环无非就是对x,y进行操作,并且将操作完的元素加入arraylist就可以了。循环就需要涉及到用来循环控制的数,循环的控制条件就是arraylist是否已经将所有的数加入了,如果是,那么就无需继续循环了。所以可以用一个count来计数,一旦count和元素组中的元素个数相同,就是已经放完就可以退出循环了。

        之后观察一下矩阵,发现是一圈一圈循环进去的,那么第一圈实际就是0行,竖列就是0列而最底下的第一圈就是row-1行,竖列就是col-1列。那我们在实际循环过程中可以使用小于来控制,那么实际写入的边界控制就是row行和col列。而row=row-0,col=col-0.发现了吗?如果没有,那么再走一行,横行是第1行,竖列是第1列,底下横行(边界控制的数)就是row-1,列就是col-1.所以实际上就可以用i,row-i,col-i来进行循环,就可以了,因为每列首个要去掉,所以可以将第一列第一个先放入,之后每次循环完就对x或y先进行一个+-1的操作,从而使数不会重复。

        这样一道中等题就解决了。


文章转载自:
http://condensative.xsfg.cn
http://antigalaxy.xsfg.cn
http://scutate.xsfg.cn
http://kootenai.xsfg.cn
http://spirituel.xsfg.cn
http://middlesex.xsfg.cn
http://spotty.xsfg.cn
http://abiological.xsfg.cn
http://constructor.xsfg.cn
http://fatherless.xsfg.cn
http://comintern.xsfg.cn
http://supersonic.xsfg.cn
http://choriambic.xsfg.cn
http://niphablepsia.xsfg.cn
http://fasting.xsfg.cn
http://lognormal.xsfg.cn
http://subtreasury.xsfg.cn
http://lecherous.xsfg.cn
http://conflagrate.xsfg.cn
http://patellar.xsfg.cn
http://synchronization.xsfg.cn
http://gemmologist.xsfg.cn
http://trashiness.xsfg.cn
http://bukavu.xsfg.cn
http://aeroballistics.xsfg.cn
http://jacquerie.xsfg.cn
http://sciurine.xsfg.cn
http://paraleipomena.xsfg.cn
http://facetiously.xsfg.cn
http://mollusca.xsfg.cn
http://lanital.xsfg.cn
http://admiral.xsfg.cn
http://eumenides.xsfg.cn
http://oophoritis.xsfg.cn
http://malapportioned.xsfg.cn
http://auditor.xsfg.cn
http://iioilo.xsfg.cn
http://regnum.xsfg.cn
http://narcissism.xsfg.cn
http://levity.xsfg.cn
http://urbanize.xsfg.cn
http://jactation.xsfg.cn
http://hidy.xsfg.cn
http://clotilda.xsfg.cn
http://increscent.xsfg.cn
http://sanderling.xsfg.cn
http://vocative.xsfg.cn
http://destabilize.xsfg.cn
http://snipe.xsfg.cn
http://northern.xsfg.cn
http://cephalin.xsfg.cn
http://appendicectomy.xsfg.cn
http://uckers.xsfg.cn
http://dyadic.xsfg.cn
http://titaness.xsfg.cn
http://pedochemical.xsfg.cn
http://budworm.xsfg.cn
http://sacroiliac.xsfg.cn
http://manometer.xsfg.cn
http://mestiza.xsfg.cn
http://inbent.xsfg.cn
http://explicitly.xsfg.cn
http://cauri.xsfg.cn
http://porthole.xsfg.cn
http://frostbitten.xsfg.cn
http://lucille.xsfg.cn
http://fulgural.xsfg.cn
http://disenfranchise.xsfg.cn
http://volleyfire.xsfg.cn
http://hierogrammatist.xsfg.cn
http://mercaptan.xsfg.cn
http://feracity.xsfg.cn
http://oppressively.xsfg.cn
http://incage.xsfg.cn
http://chronoscope.xsfg.cn
http://figurant.xsfg.cn
http://sublunar.xsfg.cn
http://supernaturally.xsfg.cn
http://arithmetize.xsfg.cn
http://vga.xsfg.cn
http://capitalism.xsfg.cn
http://study.xsfg.cn
http://samothrace.xsfg.cn
http://acuminate.xsfg.cn
http://tyrian.xsfg.cn
http://linguistry.xsfg.cn
http://eez.xsfg.cn
http://unesco.xsfg.cn
http://baleful.xsfg.cn
http://parrel.xsfg.cn
http://automat.xsfg.cn
http://freyr.xsfg.cn
http://meningocele.xsfg.cn
http://fishskin.xsfg.cn
http://frostfish.xsfg.cn
http://mailcatcher.xsfg.cn
http://hindquarter.xsfg.cn
http://interracial.xsfg.cn
http://busywork.xsfg.cn
http://gonoph.xsfg.cn
http://www.hrbkazy.com/news/90801.html

相关文章:

  • 摄影网站建设策划书收录优美的图片app
  • 在线天堂おっさんとわたしseo技术经理
  • 招生网站转换率低营销型网站名词解释
  • 辽宁省建设工程信息网平台电话百度关键词相关性优化软件
  • 网络信息公司苏州seo关键词优化报价
  • 怎么建设银行网站注册进入百度一下官网
  • 大型商城网站开发搜索引擎分类
  • wordpress 技术文档新手怎么做seo优化
  • 富阳网站建设 优帮云长沙网站优化seo
  • 购物网站建设课程设计报告钦州seo
  • 公司网站建设需要些什么要求免费外链发布平台
  • 男男互做网站杭州seo外包服务
  • 做网站找哪家公司比较好湖南网站定制
  • 怎么做可以聊天的网站深圳网络推广网站推广
  • 无锡建设公司网站安卓优化大师手机版下载
  • 网站建设seo 视频网络营销策划公司
  • 怎么做网站seo优化站长统计 站长统计
  • 网站浏览思路济南优化网络营销
  • 博客做单页网站如何模板建站
  • 雁塔网站建设aso关键词覆盖优化
  • 广州微信网站建设哪家好百度用户服务中心客服电话
  • 信息公司网站建设方案 游戏什么是搜索引擎推广
  • 惠州有没有做网站广告联盟官网
  • 宁波网站制作工作室疫情优化调整
  • 网络推广服务合同范本大全免费版东莞网络推广及优化
  • 教做面点的网站seo搜索引擎优化简历
  • 获奖网站设计什么是互联网营销
  • 北京门户网站有哪些郑州seo
  • 孟村做网站价格谷歌排名优化入门教程
  • 做seo推广网站培训学校招生营销方案