G的一道Onesite题# JobHunting - 待字闺中
d*n
1 楼
Implement a encoding system as following:
Abckkkkkkkkkkks55p=> Abc11xk55p.
Rules:
encoded them as: [n]x[c]
where n is the repetition count and c is the actual character,
X is the special character.
Decoder side:
Any time above pattern is detected, it will output n number of c.
If x is the last character, output x.
How do you handle x in the original input?
Abckkkkkkkkkkks55p=> Abc11xk55p.
Rules:
encoded them as: [n]x[c]
where n is the repetition count and c is the actual character,
X is the special character.
Decoder side:
Any time above pattern is detected, it will output n number of c.
If x is the last character, output x.
How do you handle x in the original input?