We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
longrepeatedString(constchar*s,constlongn){if(strlen(s)==1){return(s[0]=='a')?n:0;}longlongisA=0;longlen=strlen(s);for(longi=0;i<strlen(s);i++){if(s[i]=='a'){isA++;}}longlongnumberOfTimes=n/len;longlongremaining=n%len;longlongtotalA=numberOfTimes*isA;for(longi=0;i<remaining;i++){if(s[i]=='a'){totalA++;}}printf("number : %lld and isA = %ld\n",numberOfTimes,isA);returntotalA;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Repeated String
You are viewing a single comment's thread. Return to all comments →
My C code 😁😎