Front coding decoder
Your task
SSTable blocks shrink keys with front coding (prefix compression). Given a list of string keys sorted ascending, encode each key (after the first) as [shared, suffix] where shared is the length of the longest common prefix it shares with the IMMEDIATELY PRECEDING key, and suffix is the remaining characters of the key after that shared prefix. The first key is stored whole as [0, key]. To prove the encoding is lossless, DECODE it back by reconstructing each key as previous_key[:shared] + suffix, and return the decoded list of keys (which must equal the input). Keys total <= 10^5 characters.
Examples
prefix_compress_roundtrip(keys: list[str]) -> list[str]Example 1
Input
prefix_compress_roundtrip(["apple", "applet", "apply"])Output
["apple", "applet", "apply"]