Strings at Most One Edit Apart
Updated
Problem statement
Return whether first can be changed into second using at most one character insertion, deletion, or replacement.
Zero edits are allowed. Compare characters exactly, including case. Swapping two characters is not one allowed edit.
Function
atMostOneEdit(first: String, second: String) → booleanExamples
Example 1
first = "pale"second = "ple"return = trueDelete the single a from the first string.
Example 2
first = "pale"second = "bake"return = falseChanging p to b and l to k requires two replacements.
Constraints
0 <= first.length, second.length <= 5000.- Both strings contain printable ASCII characters with codes
32through126.
More Expedia Onsite Interview questions
- Scramble StringONSITE INTERVIEW · Seen Sep 2026
- Smallest Sufficient TeamONSITE INTERVIEW · Seen Sep 2026
- Check Anagram Pairs Index by IndexONSITE INTERVIEW · Seen Oct 2025
- Fresh Oranges Left After Rotting StopsONSITE INTERVIEW · Seen Oct 2025
- Longest Increasing SubsequenceONSITE INTERVIEW · Seen Oct 2025
- Lowest Common Ancestor with Repeated and Missing ValuesONSITE INTERVIEW · Seen Oct 2025
- Shortest Substring with Exactly K OnesONSITE INTERVIEW · Seen Oct 2025
- Middle Element of a Linked ListONSITE INTERVIEW · Seen Nov 2024
- Minimum in a Rotated Sorted ArrayONSITE INTERVIEW · Seen Sep 2024
- Mirror Image Binary TreesONSITE INTERVIEW · Seen Sep 2024
Similar questions at other companies
- Shortest Deletion for Distinct CharactersOracle · ONSITE INTERVIEWOracle interview questions
- Word Collection: Distance and AnagramsGoogle · ONSITE INTERVIEWGoogle interview questions
- Validate a Palindrome After Limited DeletionsMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
- Reverse File LinesCitadel · ONSITE INTERVIEWCitadel interview questions
- Longest Palindromic Substring LengthMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- All Distinct Palindromic SubstringsDoorDash · ONSITE INTERVIEWDoorDash interview questions
- String CompressionBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
- Longest Palindromic SubstringPeopleStrong · ONSITE INTERVIEWPeopleStrong interview questions
- Longest Spoken PrefixElevenLabs · ONSITE INTERVIEWElevenLabs interview questions
- Palindrome Check Ignoring SymbolsWalmart · ONSITE INTERVIEWWalmart interview questions
Interview reports that mention this question
Expedia interview experiences
- Expedia Intern Final Round in 2021: 28 Experiences (Part 4 of 6)
- Expedia Intern Finals Before 2020: 14 Experiences (Part 6 of 6)
- Expedia Intern Final Round in 2020: 24 Experiences (Part 5 of 6)
- Expedia Intern Final Round in 2022: 15 Experiences (Part 3 of 6)
- Expedia Intern Final Round in 2023: 17 Experiences (Part 2 of 6)