Beats 100% at runtime
Intuition\n Describe your first thoughts on how to solve this problem. \nStore each char in an array to avoid slow string operations. At the end remove all spac
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nStore each char in an array to avoid slow string operations. At the end remove all space characters and use join to convert to string. \n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n $$O(n)$$\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n$$O(n)$$\n\n# Code\n```javascript []\n/**\n * @param {string} encodedText\n * @param {number} rows\n * @return {string}\n */\nvar decodeCiphertext = function(encodedText, rows) {\n    const cols = encodedText.length / rows;\n    const chars = [];\n    for(let diag = 0; diag < cols; diag++)\n        for(let i = 0, j=diag; i<rows && j<cols; i++, j++)\n            chars.push(encodedText[cols*i + j]);\n    while(chars[chars.length-1] === \' \')\n        chars.pop();\n\n    return chars.join(\'\');\n};\n```
['JavaScript']