Problem · String
Minimum Changes for a Periodic Palindrome
Learn this problemProblem statement
The current password is a string currentPassword consisting only of lowercase Latin letters. Create a string newPassword of the same length that satisfies both of these requirements:
newPasswordis a palindrome.newPasswordhas a period ofk; that is,newPassword[i] = newPassword[i + k]for every1 ≤ i ≤ length(newPassword) - k.
Return the minimum number of characters that must be changed in currentPassword to create a valid newPassword.
Function
findMinChanges(currentPassword: String, k: int) → intExamples
Example 1
currentPassword = "abzzbz"k = 3return = 1Changing the first character of currentPassword to z produces zbzzbz, which is a palindrome with a period of 3. Therefore, the answer is 1.
Constraints
1 ≤ k < length(currentPassword) ≤ 2 × 10^5currentPasswordcontains only lowercase Latin letters.length(currentPassword)is divisible byk.
More Citadel problems
- Minimum Image Processing CostOA · Seen Jul 2026
- Minimum Path Sum to Target in Binary TreePHONE SCREEN · Seen Apr 2026
- Minimum Time to Process RequestsOA · Seen Mar 2026
- Process SchedulingOA · Seen Mar 2026
- Social Media SuggestionsSeen May 2025
- Best Sum Downward Tree PathSeen May 2025
- Price CheckSeen Feb 2025
- Palindromic Substrings (LC 647 :)Seen Jan 2025