LeetCode第6题:ZigZag Conversion总结

题目

The string “PAYPALISHIRING” is written in a zigzag pattern on a given >number of rows like this: (you may want to display this pattern in a >fixed font for better legibility)

P A H N
A P L S I I G
Y I R
And then read line by line: “PAHNAPLSIIGYIR”
Write the code that will take a string and make this conversion given a >number of rows:

string convert(string text, int nRows);
convert(“PAYPALISHIRING”, 3) should return “PAHNAPLSIIGYIR”.

  • 大意:把给定的一个字符串,写成指定行数的N字形(ZigZag形),然后从左到右读成新的字符串:
    problem

思路和吐槽

这道题还是没有什么高深的,只是要去找规律,推通式,我再次鄙视下自己的智商。

##代码
###Python

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注