2075. Decode the Slanted Ciphertext
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
    string decodeCiphertext(string encodedText, int rows) {
        if (encodedText.empty()) return encodedText;

        int n = encodedText.size();
        int cols = (n + rows - 1) / rows; 
        string decoded = "";
        
        for (int startCol = 0; startCol < cols; ++startCol) {
            int r = 0, c = startCol;
            while (r < rows && c < cols) {
                decoded += encodedText[r * cols + c];
                ++r;
                ++c;
            }
        }

        int endIdx = decoded.length();
        while (endIdx > 0 && decoded[endIdx - 1] == ' ') {
            --endIdx;
        }

        return decoded.substr(0, endIdx);
    }
};

```
['C++']