PracHub
QuestionsCoachesLearningGuidesInterview Prep

Quick Overview

Transform punctuation so every original run of exclamation marks gains one mark and every original period becomes exactly one exclamation mark. A single left-to-right pass preserves all other Unicode characters and avoids treating converted periods as existing runs.

  • easy
  • Upstart
  • Coding & Algorithms
  • Software Engineer

Rewrite Sentence-Ending Punctuation

Company: Upstart

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Take-home Project

# Rewrite Sentence-Ending Punctuation Transform a string in two conceptual steps: 1. Add one extra exclamation mark to every maximal run of existing `!` characters. 2. Replace every period `.` from the original string with one `!`. Return the transformed string. ### Function Signature ```python def intensify_punctuation(text: str) -> str: ... ``` ### Example ```text Input: "Hello. Nice to meet you!!" Output: "Hello! Nice to meet you!!!" ``` ### Constraints - `0 <= len(text) <= 1_000_000` - `text` may contain arbitrary Unicode characters. ### Clarifications - A run of `k` original exclamation marks becomes `k + 1` exclamation marks. - A period becomes exactly one exclamation mark; it is not treated as an original `!` and does not receive the extra mark. - Other characters are unchanged. - An empty input returns an empty string. ### Hints - A single left-to-right pass can distinguish the end of each original exclamation run.

Quick Answer: Transform punctuation so every original run of exclamation marks gains one mark and every original period becomes exactly one exclamation mark. A single left-to-right pass preserves all other Unicode characters and avoids treating converted periods as existing runs.

Transform text by adding one exclamation mark to every maximal run of original exclamation marks and replacing each original period with exactly one exclamation mark. Other Unicode characters are unchanged.

Constraints

  • The string may contain up to 1,000,000 Unicode characters.
  • A run of k original exclamation marks becomes k+1.
  • A replaced period does not receive an extra mark.
  • The empty string stays empty.

Examples

Input: ('Hello. Nice to meet you!!',)

Expected Output: 'Hello! Nice to meet you!!!'

Explanation: The supplied example.

Input: ('',)

Expected Output: ''

Explanation: The empty string is unchanged.

Hints

  1. Scan original characters only.
  2. Append the extra mark when the current original exclamation is the last in its run.
Last updated: Jul 15, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Remove Duplicate Integers While Preserving Order - Upstart (easy)
  • Scale Ingredient Quantities - Upstart (easy)
  • Compute a Point Set's Bounding Rectangle - Upstart (easy)
  • Report Where a Value Appears - Upstart (easy)
  • Interleave Three Equal-Length Strings - Upstart (easy)