Ram and Wow String

QUESTION

Ram says that a Wow String is a string that only contains vowels (a,e,i,o,u). \n\nNow, his teacher gave him a string S. He is wondering what is the length of the longest Wow string which is a substring of S.\n\nNote: Strings contains only lower case English Alphabets.\n\nInput:\n\nFirst line contains a string S,\n(1<=|S|<=10^5), where |S| denotes the length of the string.\n\nOutput:\nPrint an integer denoting the length of the longest good substring, that is substring consists of only vowels.

ANSWER

#include<stdio.h>
#include<string.h>
int main(){
 char b[100005];
 scanf("%s",b);
 int j,l,count=0,ans=0;
 l=strlen(b);
 for(j=0;j<l;j++){
  if(b[j]=='a'||b[j]=='e'||b[j]=='i'||b[j]=='o'||b[j]=='u'){
   count++;
  }
  else{
   count=0;}
  if(count>ans)
   ans=count;
 }
 printf("%d",ans);
 return 0;
}
Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
100% Free SEO Tools - Tool Kits PRO