Counting rr
Problem:-
Given a string consisting of lower-case letters . Count the total number of substring ‘rr’ present in the given string.No substring should be counted twice.
Input
Given a string s consisting of lower-case letters.
Output
Print the total number of substring ‘rr’ present in the given string.
Constraints
1 ≤ strlen(s) ≤
Input
Given a string s consisting of lower-case letters.
Output
Print the total number of substring ‘rr’ present in the given string.
Constraints
1 ≤ strlen(s) ≤
Explanation
“rr” substring is present two times in given string.
Time Limit:1.0 sec(s) for each input file.
Memory Limit:256 MB
Source Limit:1024 KB
solution:-
#include<stdio.h>
void main()
{
char s[100000];
int sum=0;
scanf(“%s”,s);
for(int i=0;s[i+1];i++)
{
if(s[i]==‘r’)
{
if(s[i+1]==‘r’)
sum++;
}
}
printf(“%d”,sum);
}