Skip to content

3330. Find the Original Typed String I #1874

Answered by mah-shamim
mah-shamim asked this question in Q&A
Discussion options

You must be logged in to vote

We need to determine the number of possible original strings Alice might have intended to type, given that she may have pressed a key for too long at most once, resulting in one or more duplicate characters in a contiguous run. The key insight is that each contiguous run of characters in the input string could be the source of the mistake, and for each run of length L, there are L-1 possible original strings (since the original run could have been of any length from 1 to L-1). Additionally, the original string without any mistake is also a possibility.

Approach

  1. Problem Analysis: The problem involves analyzing the input string to identify contiguous runs of the same character. For each s…

Replies: 1 comment 2 replies

Comment options

mah-shamim
Jul 1, 2025
Maintainer Author

You must be logged in to vote
2 replies
@kovatz
Comment options

kovatz Jul 1, 2025
Collaborator

@mah-shamim
Comment options

mah-shamim Jul 1, 2025
Maintainer Author

Answer selected by kovatz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested easy Difficulty
2 participants