Build a tool that, when given our domains and a list of other domains, alerts the user to all the possible typo-squats of our domains present in the list of other domains.
Potential kinds of typos:
- One character is wrong (substitution)
- Repeat characters (addition)
- Forget a character at end (removed character)
Part 1
Detect typos where a single character from one of our domains has been changed into a different character.
Example:
Given "Square" as one of our domains, detect:
"Sware","Smuare"
but not"Share"or"Google".
Part 2
Update the tool to restrict the changed character to only be typos that are likely, given the keyboard layout.
Example:
Given "Square" → detect:
"Swaure"
but not"Smuare"
(assuming QWERTY keyboard: Q → W likely, Q → M not likely)
Part 3
Update the tool to detect typos where our domain had an additional character added or a character removed.
Example:
Given "Square", detect:
"Squares""Squbare""Suare"
Note:
Detect only one kind of typo at a time. Do not detect "Swares" or "Suate".
Part 1 思路(替换一个字符)
- 对每个 candidate domain:
判断是否与原域名长度一致且仅有 一个位置不同 。 - 不同位置的字符数量 = 1 → 视为 typo。
Part 2 思路(结合键盘邻近字符)
- 在 Part 1 的基础上:
限制替换字符必须在 QWERTY 键盘上属于 相邻键 。 - 预先构建邻接表,例如:
Q → {W, A},W → {Q, E, S} 等。
Part 3 思路(增加字符 / 删除字符)
- 判断 candidate domain 长度与原始域名:
- +1 → 检查是否只多了一个字符
- –1 → 检查是否只少了一个字符
- 使用双指针判断是否为 one-edit difference。
VOprep 团队长期陪同学员实战各类大厂 OA 与 VO,包括 Block、Amazon、Apple、Google 等,提供实时答案助攻、远程陪练与面试节奏提醒,帮助大家在关键时刻不卡壳。
如果你也在准备公司,可以了解一下我们的定制助攻方案——从编程面到系统设计,全程护航上岸。