FastPrepClassify an Alien Dictionary Ordering
Problems/Classify an Alien Dictionary Ordering

Classify an Alien Dictionary Ordering

ZipRecruiter logoZipRecruiter● HardNEW GRADPHONE SCREENONSITE INTERVIEW

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Two ZipRecruiter live-interview reports preserve deriving alien-character precedence from adjacent sorted words and topological sorting; the richer report distinguishes unique, ambiguous, and invalid outcomes, while the other supplies the wdc/wdr/cd/dd/dr example. Prefix invalidity and literal result tokens are supplied, for an approximate 94% source match.

words is intended to be sorted under an unknown alphabet. Derive precedence edges from the first differing character of every adjacent pair and include every observed character.

  • Return the unique character order when exactly one topological ordering exists.
  • Return AMBIGUOUS when multiple orders are valid.
  • Return INVALID for a cycle or when a longer word precedes its exact prefix.

Function

alienDictionaryOrder(words: String[]) → String

Examples

Example 1

words = ["wdc","wdr","cd","dd","dr"]return = "wcdr"

The adjacent differences force the unique order wcdr.

Example 2

words = ["ab","ac"]return = "AMBIGUOUS"

Only b before c is fixed, leaving a unconstrained.

Constraints

  • 0 <= words.length <= 10000
  • The total number of lowercase letters is at most 100000.

More ZipRecruiter Phone Screen questions

  • Neighboring Record IDsPHONE SCREEN · Seen May 2026
  • Restaurant Vote LeadersPHONE SCREEN · ONSITE INTERVIEW · Seen Feb 2026
  • Most Frequent Word across Grouped ArraysPHONE SCREEN · Seen Sep 2024
  • Starting Value with the Longest Collatz ChainPHONE SCREEN · Seen Apr 2022
  • Multiset Intersection of Three ListsPHONE SCREEN · Seen Feb 2022
  • Find the Smallest Magic IndexPHONE SCREEN · Seen Dec 2021
  • Website Pair with the Most Common VisitorsPHONE SCREEN · Seen Nov 2021
  • Center-Outward Number SpiralPHONE SCREEN · Seen Jun 2021
  • Missing Ranges within Inclusive BoundsPHONE SCREEN · Seen Feb 2021
  • Fibonacci Number with Constant Extra SpacePHONE SCREEN · Seen Mar 2017

Similar questions at other companies

  • Spreadsheet Formula EvaluatorHarvey · PHONE SCREEN · ONSITE INTERVIEWHarvey interview questions
  • Alien DictionaryByteDance · PHONE SCREEN · ONSITE INTERVIEWByteDance interview questions
  • Parallel Courses IIISnowflake · ONSITE INTERVIEWSnowflake interview questions
  • Select Transactions with Child-Pays-for-Parent PackagesCoinbase · PHONE SCREENCoinbase interview questions
  • Course Order and CycleAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Choose a Road to Maximize Average Route Toll IncreaseHarness · PHONE SCREEN
  • Course Ordering with Concurrent UpdatesNuro · PHONE SCREENNuro interview questions
  • Infer a Lexicographically Smallest Alien AlphabetMicrosoft · PHONE SCREEN · ONSITE INTERVIEWMicrosoft interview questions
  • Deepest Common Ancestors in a Multi-Parent DAGSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Alien DictionaryBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions

ZipRecruiter interview experiences

  • ZipRecruiter SWE OA, Level Not Reported: 23 Experiences
  • ZipRecruiter SWE Intern OA Scores: 4 Experiences
  • ZipRecruiter SWE New Grad OA: 9 Experiences
All ZipRecruiter interview questionsSee ZipRecruiter hiring insights
Saved
class Solution {
    public String alienDictionaryOrder(String[] words) {
        // Write your code here.
    }

}
Checking account…