FastPrepLetter Order from a Sorted Word List
Problems/Letter Order from a Sorted Word List

Letter Order from a Sorted Word List

Rippling logoRippling● HardFULLTIMEPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Three reports point to one well-known puzzle: from words already sorted in an alien alphabet, work out the order of its letters. The clearest is a senior SDE phone-screen post from September 2, 2022, which also gives sample words and outputs. A senior engineer's review from September 15, 2021 records this task as its one interview question, and an August 4, 2021 post says Rippling asked a modified form of it without saying how it was modified.

In the 2022 post any valid order is accepted and the answer is -1 when no order fits. The other two reports say neither. Here the answer must be the valid order that comes first in normal a-to-z order, and an invalid list returns an empty string instead of -1. A word placed before its own prefix makes the list invalid, equal neighboring words are allowed, and the limits and examples are our own.

Our version is about 80% the same as the reported questions.

A made-up alphabet uses some lowercase English letters, but ranks them in its own order instead of a to z. You are given words, a list that should be sorted under that alphabet.

Two words are compared like in a normal dictionary: look at the first position where they differ, and the word whose letter there ranks lower comes first. If one word is a prefix of the other, the shorter word comes first. Equal words may sit next to each other.

Return a string that contains each letter that appears anywhere in words exactly once, ranked so that words is sorted. If more than one such string exists, return the one that comes first in ordinary a-to-z dictionary order. If no ranking can make words sorted, return an empty string "".

Function

alienOrder(words: String[]) → String

Examples

Example 1

words = ["dcb","dca","bd","ba"]return = "cdba"

Comparing neighbors gives b before a (dcb, dca), d before b (dca, bd) and d before a (bd, ba). Letter c has no rule, so it can go first. The smallest valid order is "cdba".

Example 2

words = ["kite","kit"]return = ""

"kit" is a prefix of "kite", so "kite" must come after it. No alphabet can fix that, so the answer is "".

Example 3

words = ["zy","yz","zz"]return = ""

"zy" before "yz" needs z before y, and "yz" before "zz" needs y before z. Both cannot hold, so the answer is "".

Constraints

  • 1 <= words.length <= 500
  • 1 <= words[i].length <= 20
  • words[i] consists only of lowercase English letters.

More Rippling Phone Screen questions

  • Filter, Sort, and Deduplicate Scheduled TasksPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Stateful Log Transform and SearchPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Dependency-Aware Task SchedulerPHONE SCREEN · Seen Nov 2026
  • Delivery Cost Tracker with Effective-Dated RatesPHONE SCREEN · Seen Nov 2026
  • Camel CardsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Best and Worst Camel Card CompletionsPHONE SCREEN · Seen Nov 2026
  • Corporate Card Expense RulesOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • In-Memory Priority Task SchedulerPHONE SCREEN · Seen Oct 2026
  • Limit an Organization Tree's HeightPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Median Across N Sorted ArraysPHONE SCREEN · Seen Oct 2026

Similar questions at other companies

  • Alien DictionaryByteDance · PHONE SCREEN · ONSITE INTERVIEWByteDance interview questions
  • Select Transactions with Child-Pays-for-Parent PackagesCoinbase · PHONE SCREENCoinbase interview questions
  • Infer a Lexicographically Smallest Alien AlphabetMicrosoft · PHONE SCREEN · ONSITE INTERVIEWMicrosoft interview questions
  • Alien DictionaryBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
  • Alien DictionaryAmazon · ONSITE INTERVIEW
  • Recover an Alien Alphabet from Sorted WordsOpenAI · PHONE SCREENOpenAI interview questions
  • Parallel Courses IIIGoogle · ONSITE INTERVIEWGoogle interview questions
  • Linked Merchants Within Two HopsStripe · PHONE SCREENStripe interview questions
  • Evaluate Formulas with Cycle DetectionInstacart · PHONE SCREEN · ONSITE INTERVIEWInstacart interview questions
  • Password From Ordering HintsRogo · ONSITE INTERVIEW

Interview reports that mention this question

  • Rippling SWE Loops and History: 23 Experiences (Part 10 of 12)
  • Rippling Older SWE Interviews: 11 Experiences (Part 11 of 12)

Rippling interview experiences

  • Rippling No-Level Older Reports: 31 Experiences (Part 6 of 6)
  • Rippling No-Level Onsite Loops: 24 Experiences (Part 5 of 6)
  • Rippling No-Level Screens and Loops: 18 Experiences (Part 4 of 6)
  • Rippling No-Level Coding Screens: 37 Experiences (Part 3 of 6)
All Rippling interview questionsSee Rippling hiring insights
Saved
class Solution {
    public String alienOrder(String[] words) {
        // Write your code here.
    }
}
Checking account…