forked from RyanFehr/HackerRank
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution.java
More file actions
31 lines (28 loc) · 761 Bytes
/
Solution.java
File metadata and controls
31 lines (28 loc) · 761 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//Problem: https://www.hackerrank.com/challenges/mars-exploration
//Java 8
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String S = in.next();
int count = 0;
int currentPos = 0;
for(char letter : S.toCharArray())
{
if(currentPos % 3 == 1)
{
count += (letter != 'O') ? 1 : 0;
}
else
{
count += (letter != 'S') ? 1 : 0;
}
currentPos++;
}
System.out.println(count);
}
}