Problem · String
Normalize a DNS Domain Name
Learn this problemProblem 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) → StringExamples
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
- Banking System, Part 1: Accounts and TransfersOA · Seen Jul 2026
- Banking System, Part 2: Top SpendersOA · Seen Jul 2026
- Banking System, Part 3: Scheduled PaymentsOA · Seen Jul 2026
- Banking System, Part 4: Merging and Balance HistoryOA · Seen Jul 2026
- Convert Stack Samples to Trace EventsPHONE SCREEN · Seen Jul 2026
- Cloud Storage SystemOA · Seen Jun 2026
- Repair the Bootloader ProgramONSITE INTERVIEW · Seen Jun 2026
- Worker Management, Part 4: Double-Paid IntervalsOA · Seen May 2026