CiscoOA #5
Minimum Password Update Operations
Estimated MediumJudge-ready
Topics (AI-labelled)SubsequencesString DP
Transform the current password into the target password. Each operation inserts or deletes exactly one character, and a substitution cannot count as a single operation. Characters cannot be reordered; all characters are counted by Unicode code point, and whitespace, NUL, emoji, and case differences are preserved.
Input
Two lines, each a JSON string, giving the current and target passwords in order; for example, the empty string is written as "", NUL as \u0000, and a newline character as \n. Strings are not split on whitespace. The original gave no bounds on length, character domain, or non-emptiness; this site adds 0..1000 Unicode scalar characters per string. The source C++ getline also supports spaces.
Output
Output a single integer, the answer.
Example 1
Input:
"password"
"pss$w#rd"
Output:
4
Example 2
Input:
"a"
"A"
Output:
2
Example 3
Input:
""
"\u0000 😀"
Output:
3
Example notes
The outputs of the three public examples are, in order: 4; 2; 3. Verified by independent enumeration or direct simulation.
Editorial
Loading solution…