#3303

Find the Occurrence of First Almost Equal Substring

hard · 15.4% accepted · 74 likes · top 0%

string · string matching

⊣ practice⊣ open on leetcode ↗

Description

You are given two strings s and pattern.

A string x is called almost equal to y if you can change at most one character in x to make it identical to y.

Return the smallest starting index of a substring in s that is almost equal to pattern. If no such index exists, return -1.

A substring is a contiguous non-empty sequence of characters within a string.

Solution