基于python超简洁的顺时针打印矩阵
来源:互联网 发布:python list太大拆分 编辑:程序博客网 时间:2024/06/09 17:28
# -*- coding:utf-8 -*-class Solution: # matrix类型为二维列表,需要返回列表 def printMatrix(self, matrix): # write code here res=[] n=len(matrix) m=len(matrix[0]) if m==1 and n==1: res=[matrix[0][0]] return res else: for o in range((min(m,n)+1)//2): [res.append(matrix[o][i]) for i in range(o,m-o)] [res.append(matrix[j][m-o-1]) for j in range(o,n-o) if matrix[j][m-o-1] not in res] [res.append(matrix[n-o-1][k]) for k in range(m-1-o,o-1,-1) if matrix[n-o-1][k] not in res] [res.append(matrix[l][o]) for l in range(n-1-o,o-1,-1) if matrix[l][o] not in res] return res
0 0
- 基于python超简洁的顺时针打印矩阵
- Python :顺时针打印矩阵
- 矩阵的顺时针打印
- 20顺时针打印矩阵python
- 顺时针打印nxn的矩阵
- 【Codewars-snail】顺时针打印矩阵(python)
- Spiral Matrix所谓的顺时针打印矩阵
- 顺时针打印矩阵
- 顺时针打印矩阵
- 顺时针打印矩阵
- 顺时针打印矩阵
- 顺时针打印矩阵
- 顺时针打印矩阵
- 顺时针打印矩阵
- 顺时针打印矩阵
- 顺时针打印矩阵
- 顺时针打印矩阵
- 矩阵顺时针打印
- java系统高并发解决方案(转载)
- SpringMVC学习-->控制反转(IoC)与依赖注入(DI
- shell 命令
- 【上级笔试之一】数据输入
- Android 手机号中间四位为* 和只取后四位
- 基于python超简洁的顺时针打印矩阵
- GitHub for Windows 安装异常解决办法
- openssl_aes
- Jeesite Login 登录 分析
- 成为专业程序员路上用到的各种优秀资料、神器及框架
- 常用ansible命令
- alpha测试和betal测试
- 推荐系统基础知识
- webpack入门必知必会