Question bank › Strings
Dsa Strings Medium

Minimal K-Periodic Edits

A string S is K-periodic if S[i] == S[i+K] for all valid i. Given an integer K and a string S, calculate the minimum number of character changes required to make the string K-periodic. You can change any character to any other uppercase letter. Input format: Line 1: The integer K Line 2: The string S Example: Input: 2 ABCDE Output: 3 (Possible result 'ABABA', changes C, D, E)

Key concepts

stringsfrequency countoptimization

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.