Rewrite Sentence-Ending Punctuation

Last updated: July 5, 2026

Quick Overview

The candidate is asked to write a function that rewrites sentence-ending punctuation in a given text, ensuring that sentences conclude with a single period.

Upstart
Coding & Algorithms
Software Engineer
Upstart
July 5, 2026
Software Engineer
Online Assessment
Coding & Algorithms
Easy

2

0

21 solved


The candidate is asked to write a function that rewrites sentence-ending punctuation in a given text, ensuring that sentences conclude with a single period.

This question is typically asked during the online assessment round to evaluate a candidate's coding skills and understanding of string manipulation. The interviewer is looking for clarity in the candidate's thought process, their ability to handle edge cases, and their proficiency in writing clean, efficient code.

What the Interviewer Expects
  • Identify and handle different types of sentence-ending punctuation.
  • Ensure that only one period is used at the end of each sentence.
  • Consider edge cases, such as multiple punctuation marks or no punctuation at all.
  • Write clean and efficient code with proper variable naming.
  • Include comments to explain the logic where necessary.
Key Topics to Cover
String manipulation
Regular expressions
Edge cases
Code efficiency
Testing
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you modify your solution to handle different languages?
  • Can you explain how you would test your function for edge cases?
  • What would you do if the input text is extremely large?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Approach

To solve the problem of rewriting sentence-ending punctuation, I will iterate through the text and identify the end of each sentence based on punctuation marks. The goal is to ensure that each sentenc...

Algorithm
  1. Initialize an empty result string.
  2. Loop through each character in the input text.
  3. Check if the character is a sentence-ending punctuation (., !, ?).
  4. If it is, append a period to the result...

Submit Your Answer
Markdown supported

Related Questions