Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class BackspaceCompare {
- func backspaceCompare(_ S: String, _ T: String) -> Bool {
- var s = ""
- var t = ""
- for ch in S{
- if ch == "#" && s.count > 0{
- s.removeLast()
- }else if ch != "#"{
- s.append(ch)
- }
- }
- for ch in T{
- if ch == "#" && t.count > 0{
- t.removeLast()
- }else if ch != "#"{
- t.append(ch)
- }
- }
- return s == t
- }
- }
Add Comment
Please, Sign In to add comment