Question: This is the question This is the answer #include int main(){ int n,k,i,j; scanf(%d%d,&n,&k); char c[n]; scanf(%s,c); int arr[26]={0}; //To use Ascii value /*max is
This is the question

![n,k,i,j; scanf("%d%d",&n,&k); char c[n]; scanf("%s",c); int arr[26]={0}; //To use Ascii value /*max](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f452d9e71e7_02566f452d9714b6.jpg)
This is the answer
#includeint main(){ int n,k,i,j; scanf("%d%d",&n,&k); char c[n]; scanf("%s",c); int arr[26]={0}; //To use Ascii value /*max is taken to find out max value for every time taking a character in consideration while max1 is taken to find out max value over all operation*/ int max=0,max1=0; for( i=0;i max){ /*checking max value of the first kth elements*/ max=v; max1=max; } } for(i=k;i max){ max=arr[j]; } } if(max1 please explain more in detail about the code so that I can understand
A substring of a string is a contiguous sequence of characters from the string. For example, BC is a substring of ABCD which starts from the second character of ABCD. Another example, ABC is a substring of ABCD which starts from the first character of ABCD. Note that ABCD itself is also a substring of ABCD. In this problem, we define a special substring as a non-empty substring that contains only the same character. For example, B and CC are special substrings of ABBCCC, while ABBC and BC are not special substrings. You are given a string S of length N and an integer K. Your task is to determine the minimum number of characters of S that need to be changed such that there exists a special substring of length K in S. For example, let N = 6, K = 4, and S = ABBCCC. In this example, we only need to change the third character of Sto C (i.e. ABBCCC + ABCCCC) so that we have a special substring cccc of length 4. Input Input begins with a line containing two integers: N K(1 SKSN
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
