FastPrepAlien Dictionary Order
Problems/Alien Dictionary Order

Alien Dictionary Order

Google logoGoogle● HardNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report names the classic Alien Dictionary interview task. This version picks the alphabetically smallest valid order and spells out what to do with an invalid prefix. Our version is about 94% the same as the reported question.

A list of words is sorted according to an unknown alphabet over the lowercase English letters that appear in the list.

Return the lexicographically smallest character ordering consistent with the word list. Include every distinct character that appears. Return an empty string when the ordering is impossible because of a cycle or because a longer word appears immediately before a shorter word that matches its beginning.

Function

alienOrder(words: String[]) → String

Examples

Example 1

words = ["wrt","wrf","er","ett","rftt"]return = "wertf"

Adjacent word comparisons imply w<e<r<t<f.

Example 2

words = ["z","x","z"]return = ""

The list implies both z<x and x<z.

Example 3

words = ["abc","ab"]return = ""

A longer word cannot precede its exact prefix in a valid lexicographic order.

Constraints

  • 1 <= words.length <= 10000.
  • 1 <= words[i].length <= 100.
  • Words contain lowercase English letters.

More Google Phone Screen questions

  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Periodic-Color Binary Forest RootsPHONE SCREEN · Seen Nov 2026
  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Best Stock Trade with Buy and Sell DaysPHONE SCREEN · Seen Nov 2026
  • Word Chain Jumps in a GridPHONE SCREEN · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Apartment Housemate PreferencesPHONE SCREEN · Seen Nov 2026
  • Price at Query TimestampsPHONE SCREEN · Seen Nov 2026
  • Course Schedule Cycle DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Alien DictionaryByteDance · PHONE SCREEN · ONSITE INTERVIEWByteDance interview questions
  • Infer a Lexicographically Smallest Alien AlphabetMicrosoft · PHONE SCREEN · ONSITE INTERVIEWMicrosoft interview questions
  • Recover an Alien Alphabet from Sorted WordsOpenAI · PHONE SCREENOpenAI interview questions
  • Letter Order from a Sorted Word ListRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
  • Alien DictionaryAirbnb · PHONE SCREEN · ONSITE INTERVIEWAirbnb interview questions
  • Evaluate Formulas with Cycle DetectionInstacart · PHONE SCREEN · ONSITE INTERVIEWInstacart interview questions
  • Validate CSV References and Field DependenciesStripe · PHONE SCREENStripe interview questions
  • Alien DictionaryIntuit · OAIntuit interview questions
  • Alien DictionaryBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
  • Alien DictionaryAmazon · ONSITE INTERVIEW

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
  • Google Experienced SWE First Round and Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public String alienOrder(String[] words) {
        // Write your code here.
    }
}
Checking account…