Count ROR

Gary is given a string containing only ‘R’s and ‘O’s (uppercase). Gary wants to count the total number of subsequences forming “ROR” in the given string. You need to return the count of subsequences possible.

Input Format :
String S (that contains R & O only)
Output Format :
Required count
Constraints :

1<= Length of String S <=10^6

Sample Input 1:
OROR
Sample Output 1:
1
Sample Input 2:
RRORR
Sample Output 2:
4

Login to submit your solution

Fb dab53a1a64929320dc7425896aa73fd9e5512b6ab52e414ff5f3ebb5cecc73eb

Share Problem