As reported: Omnissa (formerly VMware) Senior Python Developer, Bengaluru (2026), round 2, second coding problem: given two strings, check whether one can be converted into the other with at most one insertion, deletion or replacement. An
O(n)time /O(n)space answer was given; the interviewer expectedO(1)space.
Given strings s and t, return true if they are exactly one edit apart: one character inserted, deleted or replaced. This is LeetCode 161 — One Edit Distance.
Example 1
s = "ab", t = "acb" -> true (insert 'c')
Example 2
s = "", t = "" -> false (zero edits apart)
Clarifications
- In the round the question was "at most one" edit; LeetCode's version asks for exactly one, so equal strings return
falsehere. Supporting "at most one" only changes that final check.
Constraints: 0 ≤ s.length, t.length ≤ 10^4; lowercase letters, uppercase letters and digits. Use O(1) extra space.
Code runner format: one JSON value per line: s, then t (LeetCode's format). Implement isOneEditDistance(s, t); the harness prints true or false.