
g0001_0100.s0006_zigzag_conversion.Solution.swift Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of leetcode-in-all Show documentation
Show all versions of leetcode-in-all Show documentation
104 LeetCode algorithm problem solutions
// #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