Decode the Slanted Ciphertext Beats 100% of other solutions. O(n)
IntuitionThe first intuition is that the values are in diagonals of a matrix. So if we can someohow transform the row, col of a matrix into a singular index val
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
The first intuition is that the values are in diagonals of a matrix. So if we can someohow transform the row, col of a matrix into a singular index values then we can use that index value to extract the exact characters from the string.
We are given number of rows and we are given a decoded text. So we have the numbers of characters in a matrix. Now we can find out the number of columns in the cipher matrix which is lengthOfString/rows. Once we know the number of columns then it is easy for us to do a diagonal traversal of the cipher matrix. 
When we traverse diagonally we can transform the row, col values into index by this formula 
stringCharacterIndex = (rowIndex * ColumnLength) + columnIndex.
# Approach
<!-- Describe your approach to solving the problem. -->
1. Get the columnLength from encodedText.Length/ rows.
2. Initialize a new String builder.
3. Start diagonal traversal, by looping through a column for loop and inside it start a while loop with two variables x and y. X is pegged at 0 and y is pegged at col. So for every pass of col, x starts from 0, y starts from col and they increment until they are less than rowLength and column length respectively.
4. Inside the inner while loop, generate the character index from the x and y index using the formula, charIndex = (rowIndex * colLength) + colIndex.
5. Once we have the character index, get the character from the decoded text string and append it to the string builder.
6. At the end of the loop remove the trailing zeroes from the stringBuilder using TrimEnd() method.
7. Convert string builder to string and return.
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
O(N)
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
O(N)
# Code
```csharp []
public class Solution {
    public string DecodeCiphertext(string encodedText, int rows) 
    {
        var colLength = encodedText.Length / rows;
        var sb = new StringBuilder();

         for(var col = 0; col < colLength; col++)
         {
                var x = 0;
                var y = col;
                while(x < rows && y < colLength)
                {
                    var currIndex = (x * colLength) + y;
                    var currValue = encodedText[currIndex];
                    sb.Append(currValue);
                    x++;
                    y++;
                }
          
        }

        var res = sb.ToString();
        return res.TrimEnd();
        
    }
}
```
['C#']