Z-conversion of strings

 

 

 

 

class Solution(object):
    def convert(self, s, numRows):
        if numRows==1:
            return s
        res = ['' for _ in range(numRows)]
        # Cycle
        T = numRows + numRows -2
        for i in range(len(s)):
            t_num% t = t
            temp = t_num if t_num<numRows else numRows-(t_num)%numRows-2
            res[temp] += s[i] 
        return ''.join(res)

Guess you like

Origin www.cnblogs.com/topass123/p/12695101.html