---
title: "844. Backspace String Compare"
url: "https://laigary.com/interview/coding/844-backspace-string-compare"
type: "note"
section: "coding"
date: "2025-04-02"
updated: "2025-04-02"
tags: ["Stack"]
---

# 844. Backspace String Compare

[844\. Backspace String Compare](https://leetcode.com/problems/backspace-string-compare/)  

```python
class Solution:
    def backspaceCompare(self, s: str, t: str) -> bool:
        
        a = []
        for i in range(len(s)):
            if s[i] == '#':
                if len(a) > 0:
                    a.pop()
            else:
                a.append(s[i])
        
        b = []
        for i in range(len(t)):
            if t[i] == '#':
                if len(b) > 0:
                    b.pop()
            else:
                b.append(t[i])
        
        return ''.join(a) == ''.join(b)

        
```
