From d1072951d0247e32ba62e2b9c0800359b31e605a Mon Sep 17 00:00:00 2001 From: Alexandr Rutkowski Date: Sat, 4 Apr 2026 16:16:23 +0200 Subject: [PATCH] Go --- .../main.go | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 leetcode/2075. Decode the Slanted Ciphertext/main.go diff --git a/leetcode/2075. Decode the Slanted Ciphertext/main.go b/leetcode/2075. Decode the Slanted Ciphertext/main.go new file mode 100644 index 0000000..2e840b3 --- /dev/null +++ b/leetcode/2075. Decode the Slanted Ciphertext/main.go @@ -0,0 +1,30 @@ +package main + +import "strings" + +func decodeCiphertext(encodedText string, rows int) string { + if rows == 0 { + return "" + } + + var ( + n = len(encodedText) + cols = n / rows + sb strings.Builder + ) + + for idx := range cols { + r, c := 0, idx + + for r < rows && c < cols { + sb.WriteByte(encodedText[r*cols+c]) + + r += 1 + c += 1 + } + } + + result := strings.TrimRight(sb.String(), " ") + + return result +}