Was asked this today
Imagine you're building a security tool that scans documents for secret keywords. But the scanner isn’t perfect, it might misread one character in a stretch of text.
So, given a scanned document s and a target keyword pattern, your job is to find the first place in s where the text is almost the same as pattern, meaning it can match if at most one character is changed.
If there’s no such match, return -1.
Tried using a bunch of things including KMP to solve optimally but ran out of time. The interviewer said my overall idea is correct but asked me to explore other string matching algo
but I only knew KMP :/
Edit: I did propose sliding window but interivewer mentioned its suboptimal and expected time comlexity is O(n + m)
Recruiter called today to let me know its a rejection