A string originalText is encoded using a slanted transposition cipher onto a matrix with a given number of rows.
The encoding process works as follows:
A matrix is formed with rows rows and a number of columns such that originalText fits completely.
Characters of originalText are filled diagonally starting from the top row, moving from cell
Any unused cells in the matrix are filled with spaces ' '.
The encoded string encodedText is formed by reading the matrix row by row from top to bottom, from left to right.
Given the encoded string encodedText and the integer rows, return the decoded string originalText.
Note: The
originalTextdoes not have any trailing spaces.
Constraints:
encodedText.length
encodedText consists of lowercase English letters and ' ' only.
encodedText is a valid encoding of some originalText that does not have trailing spaces.
rows
The testcases are generated such that there is only one possible originalText.
A string originalText is encoded using a slanted transposition cipher onto a matrix with a given number of rows.
The encoding process works as follows:
A matrix is formed with rows rows and a number of columns such that originalText fits completely.
Characters of originalText are filled diagonally starting from the top row, moving from cell
Any unused cells in the matrix are filled with spaces ' '.
The encoded string encodedText is formed by reading the matrix row by row from top to bottom, from left to right.
Given the encoded string encodedText and the integer rows, return the decoded string originalText.
Note: The
originalTextdoes not have any trailing spaces.
Constraints:
encodedText.length
encodedText consists of lowercase English letters and ' ' only.
encodedText is a valid encoding of some originalText that does not have trailing spaces.
rows
The testcases are generated such that there is only one possible originalText.