<awangdev>844. Backspace String Compare_2.java
private String build(String s) {

        Stack<Character> stack = new Stack<>();
        for (char c : s.toCharArray()) {
            if (c != '#') stack.push(c);
            else if (!stack.isEmpty()) stack.pop();
        }
        StringBuffer sb = new StringBuffer();
        while (!stack.isEmpty()) sb.insert(0, stack.pop());
        return sb.toString();
    }
private String var_0 ( String var_2 ) {
  Stack < Character > var_5 = new Stack < > ( ) ;
  for ( char var_7 : var_2 . toCharArray ( ) ) {
    if ( var_7 != '#' ) var_5 . push ( var_7 ) ;
    else if ( ! var_5 . isEmpty ( ) ) var_5 . pop ( ) ;
  }
  StringBuffer var_13 = new StringBuffer ( ) ;
  while ( ! var_5 . isEmpty ( ) ) var_13 . insert ( 0 , var_5 . pop ( ) ) ;
  return var_13 . toString ( ) ;
}
