We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c29051c commit 73ebbd1Copy full SHA for 73ebbd1
Algorithms/Strings/Mars Exploration/Solution.java
@@ -0,0 +1,31 @@
1
+//Problem: https://www.hackerrank.com/challenges/mars-exploration
2
+//Java 8
3
+import java.io.*;
4
+import java.util.*;
5
+import java.text.*;
6
+import java.math.*;
7
+import java.util.regex.*;
8
+
9
+public class Solution {
10
11
+ public static void main(String[] args) {
12
+ Scanner in = new Scanner(System.in);
13
+ String S = in.next();
14
+ int count = 0;
15
+ int currentPos = 0;
16
+ for(char letter : S.toCharArray())
17
+ {
18
19
+ if(currentPos % 3 == 1)
20
21
+ count += (letter != 'O') ? 1 : 0;
22
+ }
23
+ else
24
25
+ count += (letter != 'S') ? 1 : 0;
26
27
+ currentPos++;
28
29
+ System.out.println(count);
30
31
+}
0 commit comments