← 返回 cisco 的题目列表Look-and-Say Next Sequence
类型:qbank
Given a number as a digit string, produce the next look-and-say term by replacing each run of the same digit with `count` followed by that digit.
Requirements
Input is an integer-like digit string inputNum representing the given number.
Treat the input as a string, not as an integer to be arithmetically decomposed.
For each consecutive run of N copies of digit D, append N followed by D to the output string.
Output the resulting string.
Examples
Input:
225
Output:
2215
Explanation: two 2s followed by one 5 becomes 22 + 15.
Input:
1211
Output:
111221
Notes
Preserve leading zeros if they appear, since the task is run-length encoding over a digit string.
The output is a string, even though the input is described as an integer.