Hello Programmers/Coders, Today we are going to share solutions of Programming problems of HackerRank, Algorithm Solutions of Problem Solving Section in Java. At Each Problem with Successful submission with all Test Cases Passed, you will get an score or marks. And after solving maximum problems, you will be getting stars. This will highlight your profile to the recruiters.
In this post, you will find the solution for Mars Exploration in Java-HackerRank Problem. We are providing the correct and tested solutions of coding problems present on HackerRank. If you are not able to solve any problem, then you can take help from our Blog/website.
Use “Ctrl+F” To Find Any Questions Answer. & For Mobile User, You Just Need To Click On Three dots In Your Browser & You Will Get A “Find” Option There. Use These Option to Get Any Random Questions Answer.
Introduction To Algorithm
The word Algorithm means “a process or set of rules to be followed in calculations or other problem-solving operations”. Therefore Algorithm refers to a set of rules/instructions that step-by-step define how a work is to be executed upon in order to get the expected results.
Advantages of Algorithms:
- It is easy to understand.
- Algorithm is a step-wise representation of a solution to a given problem.
- In Algorithm the problem is broken down into smaller pieces or steps hence, it is easier for the programmer to convert it into an actual program.
Link for the Problem – Mars Exploration – Hacker Rank Solution
Mars Exploration – Hacker Rank Solution
Problem:
A space explorer’s ship crashed on Mars! They send a series of SOS
messages to Earth for help.

Letters in some of the SOS
messages are altered by cosmic radiation during transmission. Given the signal received by Earth as a string, , determine how many letters of the SOS
message have been changed by radiation.
Example
The original message was SOSSOS
. Two of the message’s characters were changed in transit.
Function Description
Complete the marsExploration function in the editor below.
marsExploration has the following parameter(s):
- string s: the string as received on Earth
Returns
- int: the number of letters changed during transmission
Input Format
There is one line of input: a single string, .
Constraints
- will contain only uppercase English letters, ascii[A-Z].
Sample Input 0
SOSSPSSQSSOR
Sample Output 0
3
Explanation 0
= SOSSPSSQSSOR, and signal length . They sent SOS
messages (i.e.: ).
Expected signal: SOSSOSSOSSOS Recieved signal: SOSSPSSQSSOR Difference: X X X
Sample Input 1
SOSSOT
Sample Output 1
1
Explanation 1
= SOSSOT, and signal length . They sent SOS
messages (i.e.: ).
Expected Signal: SOSSOS Received Signal: SOSSOT Difference: X
Sample Input 2
SOSSOSSOS
Sample Output 2
0
Explanation 2
Since no character is altered, return 0.
Mars Exploration – Hacker Rank Solution
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 numChanged = 0; for(int i = 0; i < S.length(); i++) { if(i % 3 == 1) { if(S.charAt(i) != 'O') { numChanged++; } } else { if(S.charAt(i) != 'S') { numChanged++; } } } System.out.println(numChanged); }
tadalafil usa buy cialis 5mg pill buy pills for erectile dysfunction
order cefadroxil 500mg sale lamivudine over the counter finasteride 1mg price
order diflucan 100mg for sale ciprofloxacin 1000mg tablet order ciprofloxacin 1000mg for sale
order estradiol 1mg how to buy lamotrigine order minipress 2mg pills
flagyl 200mg ca buy cephalexin generic buy keflex sale
buy mebendazole 100mg generic where to buy tretinoin without a prescription buy tadalis generic
where to buy clindamycin without a prescription order cleocin 150mg for sale sildenafil 50mg brand
avanafil 100mg price order avanafil 200mg sale order diclofenac 50mg pills
how to buy nolvadex order rhinocort pills ceftin 250mg sale
order indomethacin sale buy terbinafine without a prescription buy generic cefixime 200mg
order generic trimox 250mg order amoxicillin 250mg for sale how to buy clarithromycin
order bimatoprost pills buy robaxin pill trazodone 50mg pill
cheap catapres order clonidine 0.1mg pills spiriva 9 mcg ca
suhagra 50mg ca sildenafil canada sildenafil 150mg
purchase minomycin online pioglitazone 30mg pill order actos 30mg online
isotretinoin 40mg drug accutane 40mg pill buy azithromycin no prescription
buy leflunomide 20mg online buy generic leflunomide 10mg order azulfidine pill
buy tadalafil 5mg without prescription cheap tadalafil pills order generic tadalafil 40mg
azipro for sale omnacortil 10mg sale order neurontin 100mg without prescription
ivermectin 6 mg tablets cost stromectol prednisone order online
lasix 100mg canada doxycycline uk order albuterol 4mg generic
levitra 10mg price levitra uk generic hydroxychloroquine 200mg
buy altace paypal glimepiride oral order arcoxia 120mg
buy vardenafil pill zanaflex ca order hydroxychloroquine 200mg
asacol 800mg pills cost azelastine 10ml oral irbesartan