Problem · String

Increase Exclamations and Convert Periods

Learn this problem
EasyUpstartFULLTIMEOA

Problem statement

Transform text in two steps:

  1. Add one additional exclamation mark to every existing consecutive run of ! characters.
  2. Replace every period . with one exclamation mark.

Function

transformPunctuation(text: String) → String

Examples

Example 1

text = "Hello. Nice to meet you!!"return = "Hello! Nice to meet you!!!"

The period becomes !, and the existing run !! gains one more exclamation mark.

More Upstart problems

drafts saved locally
public String transformPunctuation(String text) {
  // write your code here
}
text"Hello. Nice to meet you!!"
expected"Hello! Nice to meet you!!!"
checking account