Skip to content

3333. Find the Original Typed String II #1878

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 the final output string displayed on her screen and a positive integer k. The original string must be of length at least k. Alice may have pressed a key for too long, resulting in multiple consecutive characters in the output. The solution involves breaking down the problem into manageable parts and using dynamic programming to count valid configurations efficiently.

Approach

  1. Problem Analysis:

    • The output string is formed by Alice possibly pressing keys for too long, leading to consecutive duplicate characters.
    • The original string is derived by reducing each consecutive run of identical…

Replies: 1 comment 2 replies

Comment options

mah-shamim
Jul 2, 2025
Maintainer Author

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

topugit Jul 2, 2025
Collaborator

@mah-shamim
Comment options

mah-shamim Jul 2, 2025
Maintainer Author

Answer selected by topugit
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 hard Difficulty
2 participants