FastPrepCumulative Typosquatting Detection
Problems/Cumulative Typosquatting Detection

Cumulative Typosquatting Detection

Palantir logoPalantir● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Palantir new grad online assessment. A firsthand FDE report and matching Version A screenshots describe three tasks that build on each other: different hosts, any number of lookalike-character swaps, and one adjacent swap. Combinations and swaps across the first dot are included.

This version uses the full combined task. We chose the input order, how to handle duplicates, empty arrays, the size limits, and the rules for non-empty trial names and hosts.

Our version is about 95% the same as the reported mechanics.

You are given trusted companyDomains and newly registered newDomains. Return the new domains that could be typos of any trusted domain.

A domain has the form name.host. Split it at its first dot: the company name contains no dot, while the host may contain more dots. All letters are lowercase.

An exact match with any trusted domain is never a typo, even when another trusted domain could match it under the rules below.

  1. Different host: The company name stays the same, but the host differs.
  2. Similar characters: Replace any number of characters using the fixed groups 1 i l ! |, s 5 $, o 0, a @, and e 3. Characters in one group are interchangeable. This rule may be combined with a host change.
  3. One adjacent swap: Also allow one adjacent pair to be swapped, including a pair containing a dot. To check this rule, undo at most one adjacent swap in the new domain before applying the earlier rules. If the swap crosses the first dot, swap that host character before treating the remaining host as replaceable.

For example, undoing the dot/r swap in palanti.rbiz gives palantir.biz, which can match palantir.com through the host-change rule. The boundary character still matters: palanti.xbiz does not match that trusted domain.

For this exercise, assume every trial after undoing a swap must still have a nonempty name and host. Return the original matching strings in their input order, keeping repeated matching entries. Empty input arrays are allowed. Treat domains as strings; no DNS lookup is needed.

Function

detectTyposquatting(companyDomains: String[], newDomains: String[]) → String[]

Examples

Example 1

companyDomains = ["palantir.com","apple.com"]newDomains = ["palantir.biz","apple.org","apple.com","appleorchard.net"]return = ["palantir.biz","apple.org"]

palantir.biz and apple.org keep a trusted company name and change its host. apple.com is a trusted domain, so it is excluded. appleorchard.net cannot match either company name under these rules.

Example 2

companyDomains = ["palantir.com","nic.ci"]newDomains = ["paiantir.com","nic.cl","palantirtechnologies.com","nlc.biz"]return = ["paiantir.com","nic.cl","nlc.biz"]

The l-to-i replacement makes paiantir.com match palantir.com. nic.cl changes the host of nic.ci. nlc.biz combines an i-to-l replacement with a host change. The longer name in palantirtechnologies.com cannot match.

Example 3

companyDomains = ["palantir.com"]newDomains = ["plaantir.com","palanti.rbiz","palanti.xbiz","palanti.rcom","palantir.com"]return = ["plaantir.com","palanti.rbiz","palanti.rcom"]

Undoing the adjacent l/a swap in plaantir.com restores the trusted name. Swapping the first dot with r in palanti.rbiz gives palantir.biz, which then matches through a host change. The same swap in palanti.rcom restores the exact trusted domain; the original candidate is still a typo. In palanti.xbiz, that swap would give the unsupported name palantix. The original trusted domain is excluded.

Constraints

  • 0 <= companyDomains.length <= 200.
  • 0 <= newDomains.length <= 200.
  • 3 <= companyDomains[i].length <= 80.
  • 3 <= newDomains[i].length <= 80.
  • Every domain uses only lowercase ASCII letters a-z, digits 0-9, !, |, $, @, and dots. Its first dot has at least one character before it and at least one after it.

More Palantir Online Assessment questions

  • Basic Item DiscountsOA · Seen Nov 2026
  • Optimize Discount Selection Under a Point BudgetOA · Seen Nov 2026
  • Stacked Item and Category DiscountsOA · Seen Nov 2026
  • Minimize Path ValueOA · Seen Sep 2024
  • No Pairs AllowedOA · Seen Sep 2024
  • REST API: Country CodesOA · Seen Feb 2024
  • Swap ParityOA · Seen Feb 2024
  • Freelance Candidate ReviewOA · Seen Nov 2023
  • Benchmarking Tool ReportOA · Seen Sep 2023
  • Count Fit Records Across PagesOA · Seen Sep 2023

Similar questions at other companies

  • Compress Editor Actions into Operational Transform OperationsReplit · OA · PHONE SCREEN · ONSITE INTERVIEW
  • Best TV Show in a GenreAdyen · OAAdyen interview questions
  • Cheating CodemakerJane Street · OAJane Street interview questions
  • Correct Apartment Bedroom CountsRamp · OARamp interview questions
  • Reflow and Fully Justify Text LinesIntuit · OAIntuit interview questions
  • Incident MonitorStripe · OAStripe interview questions
  • REST API: Highest International StudentsRippling · OARippling interview questions
  • Count Invalid Log GroupsIBM · OAIBM interview questions
  • Compare Character Arrays with BackspacesOdoo · OAOdoo interview questions
  • Slowest Key PressRoblox · OARoblox interview questions

Interview reports that mention this question

  • Palantir FDSE New Grad OA Questions: 6 Experiences (Part 2 of 2)

Palantir interview experiences

  • Palantir FDSE Experienced-Hire Interviews: 5 Experiences
  • Palantir FDSE New Grad Interviews: 5 Experiences (Part 1 of 2)
  • Palantir FDSE Intern OA and Interviews: 3 Experiences
  • Palantir FDSE Karat and Learning: 7 Experiences (Part 2 of 2)
  • Palantir FDSE OA and Interviews: 16 Experiences (Part 1 of 2)
All Palantir interview questionsSee Palantir hiring insights
Saved
class Solution {
    public String[] detectTyposquatting(String[] companyDomains, String[] newDomains) {
        // write your code here
    }

}
Checking account…