Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions suyeun84/202507/15 BOJ G5 A와 B.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
```java
import java.util.*;
import java.io.*;

public class boj12904 {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static StringTokenizer st;

static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());}

static String S;
public static void main(String[] args) throws Exception {
nextLine();
S = st.nextToken();
nextLine();
String T = st.nextToken();
System.out.println(find(T));
}

static int find(String curr) {
int len = curr.length();
if (S.equals(curr)) return 1;
else {
if (len <= 1) return 0;
}
if (curr.charAt(len-1) == 'B') {
StringBuilder sb = new StringBuilder(curr.substring(0, len - 1));
return find(sb.reverse().toString());
} else if (curr.charAt(len-1) == 'A') {
return find(curr.substring(0, len - 1));
}
return 0;
}
}
```