cswork / OA打开练习工作台

CiscoOA #15

Create New Version

估计简单评测数据准备中,可先阅读题面

考点(AI 标注)字符串

Given a string s mixing letters and single digits, build an output string by scanning s left to right:

  • Letters accumulate into a buffer buf.
  • A digit d flushes the buffer: append buf to the output d times (so d == 1 keeps it once; d == 0 discards it).
  • Whatever letters remain in buf at the end are appended as-is.

Return the resulting string.

Constraints

  • 1 ≤ len(s) ≤ 10⁴
  • s contains lowercase letters and digits 0-9.

Example 1

Input:

s = "cisco"

Output:

"cisco"

Explanation: The given string is "cisco" and contains all letters so add it to the output string (using rule number 1). So, the output will be "cisco".

Example 2

Input:

s = "cisco2india"

Output:

"ciscociscoindia"

Explanation: The given string is "cisco2india" which contains one digit '2' after "cisco" so by using rule number 2, we get "ciscocisco" and the remaining substring "india" it is added to the output string using rule number 1. So, the output is "ciscociscoindia".