Question bank › Strings
Dsa Strings Medium

Fuzzy Substring Search

Given a pattern P and a text T, find the length of the longest substring in T that matches P with at most one character mismatch. If no such substring exists (even with one mismatch), output 0. Example: Input: banana bnna Output: 4 (Explanation: 'bana' in 'banana' matches 'bnna' with one mismatch: 'a' vs 'n' at index 1, and 'n' vs 'n', 'a' vs 'a'... wait, no. 'bana' vs 'bnna' -> b=b, a!=n, n=n, a=a. Only one mismatch. Length is 4.)

Key concepts

sliding-windowstring-comparison

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.