← 返回 doordash 的题目列表Find Similar Restaurant Names
类型:online_judge
In DoorDash, the data importer occasionally makes typos, resulting in restaurant names that are very similar but not identical. Your task is to identify all restaurant names from a given list that are similar to a specified target name.
A restaurant name is considered similar if it can be transformed into the target name by swapping at most one pair of characters within the name.
Input:
A string representing the target restaurant name.
A list of strings representing restaurant names.
Output:
A list of restaurant names from the given list that are similar to the target name.
Example:
Input:
Target restaurant name: "burgerking"
List of restaurant names: ["burgreking", "burgerkin", "burgekirng", "kingburger"]
Output:
["burgreking", "burgekirng"]
(Both names can be corrected to "burgerking" by swapping a single pair of letters.)
Example
Input
burgerking
burgreking
burgerkin
burgekirng
kingburger