Beats 96% in time and 100% in space!
Complexity\n- Time complexity:\n-     O(N)\n\n- Space complexity:\n-     O(N)\n Add your space complexity here, e.g. O(n) \n\n# Code\n\nclass Solution {\npublic
# Complexity\n- Time complexity:\n-     O(N)\n\n- Space complexity:\n-     O(N)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    string decodeCiphertext(string &s, int rows) {\n        if(s=="")return "";\n        int n=s.size();\n        string ans="";\n        int col=ceil(n/rows),ct=0,l=0,tot=0;\n        for(char ch:s)tot+=(ch!=\' \');\n        while(1){\n            bool f=0;\n            for(int i=l;i<n;i+=col+1){\n                if(s[i]!=\' \')ct++;\n                ans+=s[i];\n                if(ct==tot){\n                    f=1;\n                    break;\n                }\n            }\n            if(f)break;\n            l++;\n        }\n        return ans;\n    }\n};\n```
['C++']