FastPrepCreate New Version

Create New Version

Cisco logoCisco● MediumINTERNOA

Problem statement

Create a new version of the given string by following the given rules.

Note

The digits in the input string can be negative, in which case you will append the current output string once to the output. If you encounter 0 or 1, do not append anything to the current output.

Function

createNewVersion(s: String) → String

Examples

Example 1

s = "cisco"return = "cisco"

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

s = "cisco2india"return = "ciscociscoindia"

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".

Constraints

  • 🍅🍅

More Cisco problems

See Cisco hiring insights
Saved
public String createNewVersion(String s) {
  // write your code here
}
s"cisco"
expected"cisco"
Checking account…