Solución
solution.tsTypeScript
export function decodeMessage(encoded: string, k: number): string {
const n = encoded.length
const rows = Math.ceil(n / k);
const grid = Array.from({length: rows}, () => Array(k).fill(' '))
let i = 0
for(let col = 0; col < k; col++){
for(let row = 0; row < rows; row++){
const rowMajorIndex = row * k + col
if (rowMajorIndex < n) {
grid[row][col] = encoded[i++];
}
}
}
return grid.map((row) => row.join("")).join("").trimEnd();
}0respuestas