-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path12904.java
28 lines (25 loc) · 824 Bytes
/
12904.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class AandB {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String S = br.readLine();
String T = br.readLine();
br.close();
StringBuilder sb = new StringBuilder(T);
int rep = T.length();
while(rep-- >= 0) {
if(rep + 1 == S.length()) {
if(sb.toString().equals(S)) System.out.print(1);
else System.out.println(0);
return;
}
if(sb.charAt(rep) == 'B') {
sb.deleteCharAt(rep);
sb.reverse();
}
else sb.deleteCharAt(rep);
}
}
}