Count Similar Substrings (Microsoft India)

Problem Overview

  • Count how many substrings of text are similar to key, allowing at most one swap of adjacent characters to match.
  • Input: lowercase strings key and text, with 1 ≤ length(key) ≤ length(text) ≤ 50; Output: the count.
  • Domain: string matching and text processing with tolerance for a single adjacent-character typo.
  • From Microsoft interviews (Microsoft India); a coding interview problem and common string 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: