Get String to Remove

Problem Overview

  • Determine if target X can be formed from S by placing the cursor once and pressing Backspace multiple times.
  • Inputs: strings S and X (X.length <= S.length); Output: the exact removed substring, or "-1" if not possible.
  • Real-world context: simulates text editing where Backspace deletes characters to the left of the cursor without moving the mouse.
  • This coding interview problem was asked in Onix interviews and is a common interview question.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: