happy coding
[java] 1032. 명령 프롬프트 본문
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
String[] words = new String[N];
for (int i=0 ; i< words.length ; i++) {
words[i] = br.readLine();
}
int minLength = Integer.MAX_VALUE;
for (String word : words) {
minLength = Math.min(minLength, word.length());
}
StringBuilder output = new StringBuilder();
for (int i=0 ; i<minLength ; i++) {
char currentChar = words[0].charAt(i);
boolean isSame = true;
for (String word : words) {
if (word.charAt(i) != currentChar) {
isSame = false;
break;
}
}
if (isSame) {
output.append(currentChar);
} else {
output.append('?');
}
}
System.out.println(output.toString());
br.close();
}
}
'coding study > baekjoon' 카테고리의 다른 글
[java] 10814. 나이순 정렬 (0) | 2023.08.13 |
---|---|
[java] 3052. 나머지 (0) | 2023.08.13 |
[java] 1157. 단어 공부 (0) | 2023.08.13 |
[java] 4344. 평균은 넘겠지 (0) | 2023.08.13 |
[java] 2869. 달팽이는 올라가고 싶다. (0) | 2023.08.13 |
Comments