Search
⌘K

Leetcode 3135. Equalize Strings by Adding or Removing Characters at Ends

Given two strings where you may only add or remove characters at the ends, find the minimum number of such operations to make them identical; the core challenge is to find the longest common contiguous substring (reachable by trimming ends) and compute operations = |s1|+|s2|-2*L. This reduces to a longest-common-substring problem solvable with DP, rolling hash, or suffix structures.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.