Question: By the time Agent P breaks into the evil Dr . D ' s private office, Dr . D changes his computer's password and manages
By the time Agent P breaks into the evil Dr Ds private office, Dr D changes his computer's password and manages to escape.
Dr D changed some random letters in the original password to make the new password; therefore, the new password is the same length as the old one there is no insertion or deletion of characters
The password is a string of characters, with the only possible characters being the small letters from the English alphabet a to z
Agent P knows that the new password is kbalanced. A string is kbalanced if all the substrings of length k have the same counts of all the letters a to zsee samples for more details
A string A is a substring of a string B if A can be obtained from B by deletion of several possibly zero or all characters from the beginning and several possibly zero or all characters from the end. For example, c 'fish', 'cat', 'atf', is are substrings of 'catfish', but z 'cis', 'cats',..., are not.
He also believes that Dr D was in a hurry and could not have changed many characters.
So he wants to know the minimum number of changes required in the old password to make it k balanced.
Given a string password and an integer k Help Agent P by calculating the minimum number of changes required in password so that the new password is kbalanced.
Input Format
The first line contains an integer, k denoting the integer described in the problem statement
The next line contains a string, password, denoting the old password
Constraints
k lenpassword
lenpassword
Case :
Input:
bdbab
Output:
Explanation:
k password "bdbab" all the klength substrings bdbab The count of each character is already the same in all the klength substrings.
case:
Input: baacb
Output:
Explanation:
k password "baacb" all the klength substrings baac "aacb" count of letters in "baac" is abc
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
