Leetcode-Question-6: ZigZag Conversion

题目:
ZigZag Conversion
Difficulty: Easy

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)


And then read line by line: "PAHNAPLSIIGYIR"Write the code that will take a string and make this conversion given a number of rows:

convert("PAYPALISHIRING", 3) should return "PAHNAPLSIIGYIR".

上面的方法简单直观,不过需要动态申请空间,浪费。
另一种方法就是找规律。

Updated 2017.10.02  两年前的今天,那也是一个国庆节假期。

 

发表评论

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