844 比较含退格的字符串
class Solution {
public boolean backspaceCompare(String s, String t) {
Stack<Integer> stk1 = new Stack<Integer>();
Stack<Integer> stk2 = new Stack<Integer>();
comP(stk1,s);
comP(stk2,t);
return stk1.equals(stk2);
}
static void comP(Stack stk,String s){
for(int i = 0;i<s.length();i++){
char ch = s.charAt(i);
if(ch!='#'){
stk.push(ch);
}else if(!stk.empty()){
stk.pop();
}
}
}
}