Convert Simple Password to Complex
Updated
Problem statement
A company's IT department sees users keep picking simple passwords such as "password" or "abc123". They want to turn each one into a harder password.
You are given the current password currPassword and the new password newPassword. In one change you can either insert one character anywhere or delete one character.
Return the minimum number of changes needed to turn currPassword into newPassword.
Function
minUpdates(currPassword: String, newPassword: String) → intExamples
Example 1
currPassword = "password"newPassword = "pss$w#rd"return = 4The current password is "password" and the new password is "pss$w#rd"; we need to delete 'a' and 'o' (2 operations) and insert '$' and '#' (2 operations) to convert the current password into the new password. So, the output is 4.
Constraints
1 ≤ currPassword.length, newPassword.length ≤ 1000- Both passwords contain only English letters, digits, and the symbols
! @ # $ % ^ & *.
More Cisco interview questions
- Check if a String Is a PalindromePHONE SCREEN · Seen Nov 2026
- Find Unique ElementsPHONE SCREEN · Seen Nov 2026
- First Letter to Appear TwicePHONE SCREEN · Seen Nov 2026
- Middle of a Linked ListPHONE SCREEN · Seen Nov 2026
- Reverse a Linked ListPHONE SCREEN · Seen Nov 2026
- Reverse a StringPHONE SCREEN · Seen Nov 2026
- Valid ParenthesesPHONE SCREEN · Seen Nov 2026
- K-Step Bit Flip with RetentionPHONE SCREEN · Seen Nov 2026
- Todo Task Manager OperationsONSITE INTERVIEW · Seen Oct 2026
- Find the Duplicate Number Without Modifying the ArrayONSITE INTERVIEW · Seen Sep 2026
Similar questions at other companies
- Longest Palindromic SubsequenceAXQ Capital · OA
- Maximum Equal-Bit Pairs in a SubsequenceAmazon · OA
- Longest Subsequence That Is a SubstringBooking.com · OA
- Count Digit Replacements with No Equal Adjacent DigitsMicrosoft · OAMicrosoft interview questions
- Palindrome CounterGoldman Sachs · OAGoldman Sachs interview questions
- Longest String ChainVisa · OAVisa interview questions
- Minimum-Cost Digit String DecodingSquadStack.ai · OA
- Maximum Redundancy After One Segment FlipBloomberg LP · OABloomberg LP interview questions
- Substrings Without a Target SubsequencePhonePe · OAPhonePe interview questions
- Minimum Edit-Distance String for Each QueryTarget · OA