Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- int main()
- {char a[500];
- scanf("%[^\n]s",a);
- int hash1[95];
- int I;
- for(I=0;I<95;I++)
- hash1[I]=0;
- char *p=a;
- while(*p!='\0')
- {hash1[*p-32]++;
- p++;}
- int max=0,min=strlen(a);
- int posM,posm;
- for(I=0;I<95;I++)
- {if(hash1[I]==0)
- continue;
- if(min>hash1[I])
- {min=hash1[I];
- posm=I;}
- if(max<hash1[I])
- {max=hash1[I];
- posM=I;}}//computes min and max both
- int N;//the maximum characters that can be removed
- scanf("%d",&N);
- while(N--)
- {if(min==1)
- hash1[posm]=0;
- else
- hash1[posM]--;
- max=0;
- min=strlen(a);
- for(I=0;I<95;I++)
- {if(hash1[I]==0)
- continue;
- if(min>hash1[I])
- {min=hash1[I];
- posm=I;}
- if(max<hash1[I])
- {max=hash1[I];
- posM=I;}}//computes min and max both
- }
- printf("%d\n",max-min);
- return 0;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement