package main

func ZigZagConvert(s string, numRows int) string {
	res := make([]string, numRows)
	slen := len(s)
	resStr := ""

	for i := 0; i < slen; {
		j := 0
		for ; j < numRows && i < slen; j++ {
			res[j] += string(s[i])
			i++
		}
		k := j - 2
		for k > 0 && i < slen {
			res[k] += string(s[i])
			i++
			k--
		}
	}

	for i := 0; i < numRows; i++ {
		resStr += res[i]
	}

	return resStr
}
