FastPrepAlphabetize a Word List
Problems/Alphabetize a Word List

Alphabetize a Word List

DocuSign logoDocuSign● EasyINTERNOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A report from May 2020 listed three questions from one hiring process. One asked for a big word list to be sorted into a file, with any programming language allowed. The report does not say which step it came in.

Here you get the words as a list and return the sorted list instead of writing a file. The report does not say how to treat case or repeated words. All words are lowercase. A word that is the start of another comes first. Repeated words are kept. There are 1 to 2000 words of up to 10 letters. We wrote the examples.

Our version is about 75% the same as the reported question.

You are given a list of words, words. Return the same words in alphabetical order, the way a dictionary lists them.

To decide which of two words comes first:

  • Compare them letter by letter from the left. At the first position where they differ, the word with the earlier letter in the alphabet comes first.
  • If one word runs out of letters first and every letter so far matched, the shorter word comes first. For example, "car" comes before "cart".

Keep repeated words. If a word appears 3 times in words, it appears 3 times in the answer.

Function

alphabetize(words: String[]) → String[]

Examples

Example 1

words = ["pear","fig","apple","date"]return = ["apple","date","fig","pear"]

Compare first letters: a < d < f < p. So the order is apple, date, fig, pear.

Example 2

words = ["cart","car","cat","ca"]return = ["ca","car","cart","cat"]

All four words start with ca. "ca" ends first, so it comes first. "car" is the start of "cart", so it comes before it. "cat" comes last because its third letter t is after r.

Example 3

words = ["kiwi","lime","kiwi"]return = ["kiwi","kiwi","lime"]

Repeated words stay in the list. Both copies of "kiwi" come before "lime".

Constraints

  • 1 <= words.length <= 2000
  • 1 <= words[i].length <= 10
  • Every words[i] contains only lowercase English letters.

More DocuSign Online Assessment questions

  • Max Sum With No Two Adjacent PicksOA · Seen Apr 2026
  • Max Sum With No Two Adjacent Picks on a CircleOA · Seen Apr 2026
  • Beautiful Number OrderingsOA · Seen Feb 2026
  • Grid Path With the Most ClearanceOA · Seen May 2025
  • Vehicle Mixes for a Wheel TotalOA · Seen May 2025
  • Count Sales Rung Up at the Wrong PriceOA · Seen Feb 2021
  • Most Disjoint Intervals From Starts and DurationsOA · Seen Feb 2021
  • Fewest Fountains to Water the GardenOA · Seen Feb 2021
  • Lowest Start That Keeps Running Totals PositiveOA · Seen Feb 2021
  • Fewest Student Groups Within a Level GapOA · Seen Nov 2020

Similar questions at other companies

  • Count User Mentions in Chat MessagesRamp · OARamp interview questions
  • Blood Type Inheritance: Possible Parent GenotypesAbridge · OAAbridge interview questions
  • Count Repeated Request IDs (Data Science OA)McKinsey & Company · OAMcKinsey & Company interview questions
  • Find a File in a Directory SnapshotCresta · OACresta interview questions
  • Flat JSON Value DifferencesChubb · OAChubb interview questions
  • Road Trip (Analyst Program :PBlackRock · OABlackRock interview questions
  • Get Search ResultsJP Morgan Chase · OAJP Morgan Chase interview questions
  • Lexicographic Word FrequenciesUpstart · OAUpstart interview questions
  • Email Log Processing, Grouping, and SortingStripe · OAStripe interview questions
  • Most Frequent CharacterMicrosoft · OAMicrosoft interview questions

Interview reports that mention this question

  • DocuSign SWE Intern Interviews: 27 Experiences (Part 2 of 2)

DocuSign interview experiences

  • DocuSign SWE Intern OA Questions: 53 Experiences (Part 1 of 2)
All DocuSign interview questionsSee DocuSign hiring insights
Saved
class Solution {
    public String[] alphabetize(String[] words) {
        // Write your code here.
    }
}
Checking account…