def min_changes(current_password: str, k: int) -> int:
Two problems in 75 minutes, online assessment. This is one of them.
You are given a string currentPassword and an integer k. Change currentPassword into a newPassword of the same length that meets two requirements:
newPassword is a palindrome.newPassword repeats with period k: newPassword[i] == newPassword[i + k] for every valid i.Return the minimum number of characters that must change to turn currentPassword into newPassword.
Input: currentPassword = "abzzbz", k = 3
Output: 1
Explanation: "abzzbz" -> "zbzzbz" changes one character.
Constraints
1 <= k < length(currentPassword) <= 2 * 10^5currentPassword is divisible by k.currentPassword contains only lowercase letters.Confirm on the day
k being its own palindrome. The report that posts the prompt word for word (with the example and constraints above) and a second independent report both give the two requirements above: the whole password is a palindrome and it repeats every k characters. Check which one your prompt states.Three independent reports, all Citadel online assessments with two problems in 75 minutes, from July to September 2025: two for the software engineering intern role and one for new grad. The problem is paired with a different second problem each time: maximum earnings when turning at most k days off into workdays, the minimum image-processing cost with a daily discount, or counting schedules of processes that never run twice in a row.
One intern candidate says both problems are not hard, but passing all the test cases needs a fairly fast solution. They passed both and had heard nothing back at the time of a later reply. Asked later to explain this problem, they say they have partly forgotten it, and describe mixed-case letters (case-sensitive) and every k letters forming a palindrome from the first position.
The other intern candidate posts the prompt word for word, with constraints and the example, and says they found it not very hard but solved neither problem in time. A union-find solution in JavaScript is posted later in that thread; it labels itself O(n) time and space (strictly O(n α(n)) time, effectively linear).
The new-grad candidate describes the same two requirements (a palindrome, the same character every k positions) with lowercase letters only.
The first intern report has since been reposted many times under other titles, word for word or paraphrased. The reposts are not independent reports. One paraphrase lets the last block be shorter than k, which contradicts the length being a multiple of k in the word-for-word prompt and in the detailed intern recollection; that version is not graded.
Two problems in 75 minutes, online assessment. This is one of them.
You are given a string currentPassword and an integer k. Change currentPassword into a newPassword of the same length that meets two requirements:
newPassword is a palindrome.newPassword repeats with period k: newPassword[i] == newPassword[i + k] for every valid i.Return the minimum number of characters that must change to turn currentPassword into newPassword.
Input: currentPassword = "abzzbz", k = 3
Output: 1
Explanation: "abzzbz" -> "zbzzbz" changes one character.
Constraints
1 <= k < length(currentPassword) <= 2 * 10^5currentPassword is divisible by k.currentPassword contains only lowercase letters.Confirm on the day
k being its own palindrome. The report that posts the prompt word for word (with the example and constraints above) and a second independent report both give the two requirements above: the whole password is a palindrome and it repeats every k characters. Check which one your prompt states.| Approach | Notes |
|---|---|
| Union-find over the period and mirror pairs | Posted in a thread as a JavaScript solution it labels O(n) (strictly O(n α(n))): union i with i + k and i with n - 1 - i, then keep the most common character per root. Same answer as grouping remainders r and k - 1 - r directly, with more code; the direct grouping needs no union-find arrays. |
Common mistakes: A solution that is too slow for every test case: one candidate says the problem is not hard but passing all test cases needs a fairly fast solution.
What passers do: Near-linear time: the union-find solution posted in a thread labels itself O(n) time and O(n) space (strictly O(n α(n)) time).
Why people fail: Running out of the 75 minutes: one candidate found both problems not very hard but solved neither.
Send them this page. It is free to read, no account needed.
What you just read — canonical solution, follow-up arc, what passing candidates actually did — exists for all 62 Citadel questions, refreshed monthly from new candidate reports.