Sale
Summer Offer: $190/yr $99/yr
00 : 00 : 00 : 00
Get this deal
Backend Engineer Senior programming

Given two strings s and t, return true if they are equal when both are typed into empty text editors. That means if a string contains '#' characters, these characters represent a backspace. They reduce the previous characters in the string by one. Note that no two characters in the string will be the same. Please implement the following function:


def backspaceCompare(s: str, t: str) -> bool:

Constraints:


  • 1 <= s.length, t.length <= 200

  • s and t only contain lowercase letters and '#' characters.


Example 1:


Input: s = "ab#c", t = "ad#c"
Output: true

Example 2:


Input: s = "ab##", t = "c#d#"
Output: true
Suggested Answer

Trusted by 100+ professionals preparing for interviews

Trusted by 100+ professionals 50+ Company Question Banks 5+ Supported Languages

Practice More Questions Like This

Generate unlimited interview questions with structured answers, code runner, and AI-powered walkthroughs.

Get Started Free
Link copied to clipboard