import java.util.*;
import java.math.*;
public class LeftAndRightHandedDiv2 {
public static void main(String[] args) {
LeftAndRightHandedDiv2 obj = new LeftAndRightHandedDiv2();
System.out
.println(
obj.count(
"LR"
));
}
public int count(String S) {
int c = 0;
for (int i = 1; i < S.length(); i++) {
if (S.charAt(i) == 'L' && S.charAt(i - 1) == 'R')
c++;
}
return c;
}
}
No comments:
Post a Comment