-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGoogleQ6.java
More file actions
35 lines (28 loc) · 836 Bytes
/
GoogleQ6.java
File metadata and controls
35 lines (28 loc) · 836 Bytes
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
29
30
31
32
33
34
35
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class GoogleQ6 {
private String computeString(String s) {
String retS = new String();
for (int i = 0; i < s.length(); ++i) {
Character ch = s.charAt(i);
if (ch != '#') {
retS += Character.toString(ch);
} else if (retS.length() > 0) {
retS = retS.substring(0, retS.length() - 1);
}
}
return retS;
}
public boolean backspaceCompare(String S, String T) {
S = computeString(S);
T = computeString(T);
return S.equals(T);
}
public void run() {
String str1 = "";
String str2 = "";
boolean output = backspaceCompare(str1, str2);
System.out.println(output);
}
}