Google | Onsite | Compare RLE Strings
1981

Given 2 run-length encoded strings s and t. Determine if they represent the same string.

Example 1:

Input: s = "3a1b", t = "2a1a1b"
Ouptut: true

Example 2:

Input: s = "3a1b3c", t = "2a1a1b2c1d"
Ouptut: false

Expected O(1) space solution.

Follow-up:
Given a RLE string s and a width of a board. Assume that the board is filled from left to right such that each line has exactly width chars. Output the RLE string that represents the board rows from right to left without constructing the board.

Example:

Input: s = "3a1b3c3d2a", width = 4

aaab
cccd
ddaa

Output: "1b3a1d3c2a2d"
Comments (13)