package leetcode;

/**
 * https://leetcode.com/problems/backspace-string-compare/
 */
public class Problem844 {
    public boolean backspaceCompare(String S, String T) {
        // TODO
        return false;
    }

    public static void main(String[] args) {
        Problem844 prob = new Problem844();
        System.out.println(prob.backspaceCompare("ab#c", "ad#c")); // true
        System.out.println(prob.backspaceCompare("ab##", "c#d#")); // true
        System.out.println(prob.backspaceCompare("a##c", "#a#c")); // true
        System.out.println(prob.backspaceCompare("a#c", "b")); // false
    }
}

@@ -175,36 +175,52 @@
     
-// TODO%0A        return false
+return finalString(S).equals(finalString(T))
 ;%0A  
@@ -233,21 +233,22 @@
    p
-ublic
+rivate
  static 
 void
@@ -247,30 +247,34 @@
 tic 
-void ma
+String finalStr
 in
+g
 (String
-%5B%5D arg
+ 
 s) %7B
@@ -286,340 +286,363 @@
     
-Problem844 prob = new Problem844();%0A        System.out.println(prob.backspaceCompare(%22ab#c%22, %22ad#c%22)); // true%0A        System.out.println(prob.backspaceCompare(%22ab##%22, %22c#d#%22)); // true%0A        System.out.println(prob.backspaceCompare(%22a##c%22, %22#a#c%22)); // true%0A        System.out.println(prob.backspaceCompare(%22a#c%22, %22b%22)); // false
+StringBuilder sb = new StringBuilder();%0A        for (int i = 0; i %3C s.length(); i++) %7B%0A            if (s.charAt(i) == '#') %7B%0A                if (sb.length() - 1 %3E= 0) %7B%0A                    sb.deleteCharAt(sb.length() - 1);%0A                %7D%0A            %7D else %7B%0A                sb.append(s.charAt(i));%0A            %7D%0A        %7D%0A        return sb.toString();
 %0A   

Solve problem 844