Two-line python (~105ms, 82%)

  • 1

    The idea is to sort the string according to row index and its original position

    class Solution(object):
        def convert(self, s, numRows):
            return ''.join([x for (_,_,x) in sorted(zip(i,range(len(s)),s))])

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.