반응형
USACO Uddered but not Herd
백준 20973
문제
코드
import java.util.Scanner;
public class Main {
// USACO Uddered but not Herd JAVA
// 백준 20973
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String cowStr = sc.nextLine();
String target = sc.nextLine();
int cnt = 0; //answer
int idx = 0; //target 전용 idx
while (idx < target.length()) {
++cnt;
for (int i = 0; i < cowStr.length(); i++) {
if (cowStr.charAt(i) == target.charAt(idx)) ++idx;
if (idx >= target.length()) break;
}
}
System.out.println(cnt);
}
}//class
반응형
'개발 > 알고리즘' 카테고리의 다른 글
[USACO] Mad Scientist JAVA (0) | 2021.02.23 |
---|---|
[USACO] Even More Odd Photos JAVA (0) | 2021.02.23 |
[USACO] Swapity Swap JAVA (0) | 2021.02.23 |
[USACO] Triangles JAVA (0) | 2021.02.22 |
[프로그래머스] 모의고사 JAVA (0) | 2021.02.21 |
최근댓글