[Lucky Algorithm] Mars Exploration(29/77)
Mars Exploration (Hacker Rank)
Letters in some of the SOS messages are altered by cosmic radiation during transmission. Given the signal received by Earth as a string, S, determine how many letters of Sami’s SOS have been changed by radiation.
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();
String sos = "SOS";
int result = 0;
for(int i = 0; i < S.length(); i++){
if(S.charAt(i) != sos.charAt(i%3)){
result++;
}
}
System.out.println(result);
}
}
행운의 77문제 프로젝트
행운의 77문제 프로젝트는 한 달동안 알고리즘 문제 77개를 푸는 프로젝트입니다.