当前位置:网站首页>leetcode:6. Zigzag transformation
leetcode:6. Zigzag transformation
2022-06-12 01:47:00 【Review of the white speed Dragon King】

Ideas :
Simple simulation , Pay attention to special situations numsrow = 1
src:
class Solution:
def convert(self, s: str, numRows: int) -> str:
len1 = len(s)
cnt = 0
i = 0
flag = "down"
lists = [[] for i in range(numRows)]# Establishment of two-dimensional array
while cnt < len1:
lists[i].append(s[cnt])
cnt += 1
# Special treatment
if numRows == 1:
continue
if i == 0:
flag = "down"
if i == numRows - 1:
flag = "up"
if flag == "down":
i += 1
else:
i -= 1
res = ""
for i in range(numRows):
res += "".join(lists[i])
return res
summary :
Simple simulation is enough
边栏推荐
- Point cloud perception algorithm interview knowledge points (II)
- Entity class dto to VO is converted through plug-in
- Quatre schémas de mise en file d'attente des messages pour redis
- 如何为Excel中的单元格自动填充颜色
- Redis實現消息隊列的4種方案
- [untitled]
- Explore performance optimization! Performance improvement from 2 months to 4 hours!
- 竞价广告每次点击出价多少钱是固定的吗?
- Point cloud perception algorithm interview knowledge points (I)
- 如何提高广告的广告评级,也就是质量得分?
猜你喜欢

螺旋矩阵(技巧)

Redis實現消息隊列的4種方案

Design practice of rongyun Im on electron platform

What are the advantages of adaptive search advertising?

Data in the assembly cannot start with a letter! 0 before the beginning of a letter

Perceptron from 0 to 1

Quatre schémas de mise en file d'attente des messages pour redis

kali安装empire过程中遇到的各种报错解决方案

Concepts of programs, processes, and threads

Pyinstaller packaging Exe (detailed tutorial)
随机推荐
Redis实现消息队列的4种方案
Unit tests in golang
[learn FPGA programming from scratch -20]: quick start chapter - operation steps 4-2-quick use of Altera quartz II tool (Modelsim co simulation, program download to altera development board)
php安全开发 13博客系统的栏目模块的编写
[从零开始学习FPGA编程-20]:快速入门篇 - 操作步骤4-2-Altera Quartus II工具的快速使用(modelSim联合仿真、程序下载到Altera开发板)
Linux(CentOS7)安裝MySQL-5.7版本
How to access the traifik proxy dashboard using the rancher desktop
How much coverage is appropriate for children's serious illness insurance? Which product is the best?
通过搜索广告附加信息让广告更具相关性
How to locate keywords to make advertising accurate.
Installing mysql-5.7 for Linux (centos7)
Loop loop and CX
Leetcode 55 jump game
MySQL实训报告【带源码】
A mystery of the end of vagrant up
Quatre schémas de mise en file d'attente des messages pour redis
Redis實現消息隊列的4種方案
Prism框架初识-模块化介绍
"C'est plus sûr d'apprendre une technologie!" Hangzhou Campus Little Brother transfer software test, Hi - Ti 10K + double break!
How to improve the advertising rating of advertising, that is, the quality score?