FastPrepNormalize a DNS Domain Name
Problems/Normalize a DNS Domain Name

Normalize a DNS Domain Name

Anthropic logoAnthropic● EasyINTERNOA
QuestionFunctionExamples

Problem statement

Implement normalizeDnsName for the first step of a DNS resolver.

  • DNS names are case-insensitive, so convert every letter to lowercase.
  • By convention, a normalized DNS name ends with a trailing period (.). If the input does not already end with one, append it.

Function

normalizeDnsName(name: String) → String

Examples

Example 1

name = "Anthropic.COM"return = "anthropic.com."

The name is lowercased and receives the conventional trailing period.

Example 2

name = "api.Anthropic.com."return = "api.anthropic.com."

The existing trailing period is preserved rather than duplicated.

More Anthropic problems

  • Fair Coin from a Biased CoinPHONE SCREEN · Seen Nov 2026
  • Crawl Same-Hostname URLs ConcurrentlyPHONE SCREEN · Seen Oct 2026
  • Longest-Match Tokenizer with Unknown SymbolsONSITE INTERVIEW · Seen Oct 2026
All Anthropic interview questionsSee Anthropic hiring insights
Saved
class Solution {
    public String normalizeDnsName(String name) {
      // write your code here
    }

}
Checking account…