Decode the Slanted Ciphertext
A string originalText is encoded using a slanted transposition cipher to a string encodedText with the help of a matrix having a fixed number of rows rows.
originalText is placed first in a top-left to bottom-right manner. Cells are filled diagonally from top-left to bottom-right until reaching the end of originalText. All empty cells are filled with ' '. The number of columns is chosen such that the rightmost column will not be empty after filling in originalText.
encodedText is then formed by appending all characters of the matrix in a row-wise fashion.
Given the encoded string encodedText and number of rows rows, return the original string originalText.
Note: originalText does not have any trailing spaces ' '. The test cases are generated such that there is only one possible originalText.
encodedText = "ch ie pr", rows = 3"cipher"encodedText = "iveo eed l te olc", rows = 4"i love leetcode"originalText can be traversed diagonally to recover i love leetcode.Constraints
- 0 <= encodedText.length <= 10^6
- encodedText consists of lowercase English letters and ' ' only.
- encodedText is a valid encoding of some originalText that does not have trailing spaces.
- 1 <= rows <= 1000
- The testcases are generated such that there is only one possible originalText.