g0001_0100.s0006_zigzag_conversion.Solution.swift Maven / Gradle / Ivy
// #Medium #String #2024_06_19_Time_26_ms_(72.18%)_Space_16.6_MB_(44.74%)
class Solution {
func convert(_ s: String, _ numRows: Int) -> String {
let arr = Array(s)
var result = ""
let shift = numRows > 1 ? (numRows - 1) * 2 : 1
var index = 0
for row in 0.. © 2015 - 2025 Weber Informatics LLC | Privacy Policy