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
July 5, 20262
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
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- 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 ProblemsSample 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
- Initialize an empty result string.
- Loop through each character in the input text.
- Check if the character is a sentence-ending punctuation (., !, ?).
- If it is, append a period to the result...