We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
publicstaticintmarsExploration(Strings){// Write your code here/* * Ideas: - String s has similar subsections and it was supposed to be "SOS" every 3 words - Find the number of subsections and check in each subsection with the term "SOS" *///Init varsintnumSubSec=s.length()/3;intdiffs=0;for(inti=0;i<numSubSec;i++){if(s.charAt(3*i)!='S')diffs++;if(s.charAt(3*i+1)!='O')diffs++;if(s.charAt(3*i+2)!='S')diffs++;}returndiffs;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Mars Exploration
You are viewing a single comment's thread. Return to all comments →
My solution in Java: