PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Meta

Check and infer custom alphabet

Last updated: Mar 29, 2026

Quick Overview

This question evaluates understanding of string comparison under a custom lexicographic order, the ability to validate whether a list of words is sorted according to that order, and the ability to infer a consistent character precedence from an ordered list.

  • hard
  • Meta
  • Coding & Algorithms
  • Software Engineer

Check and infer custom alphabet

Company: Meta

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Technical Screen

You are working with an unknown language that uses a custom alphabetical order, such as `['a', 'd', 'c', 'b', ...]`. Implement the following: 1. **Check sorted order**: Given a custom alphabet order and an array of strings, determine whether the strings are sorted in nondecreasing lexicographic order under that alphabet. 2. **Follow-up**: Given an array of strings that is already sorted according to an unknown custom alphabet, infer **one possible** alphabet order that is consistent with the given list. If no valid order exists, return that it is impossible. Assumptions: - All strings consist of lowercase letters. - Lexicographic comparison is based on the first differing character. - If one word is a prefix of another, the shorter word must come first. - In the follow-up, if multiple valid alphabet orders exist, returning any one of them is acceptable.

Quick Answer: This question evaluates understanding of string comparison under a custom lexicographic order, the ability to validate whether a list of words is sorted according to that order, and the ability to infer a consistent character precedence from an ordered list.

Related Interview Questions

  • Solve Two Backtracking Array Problems - Meta (hard)
  • Solve Array, Matrix, and Recommendation Problems - Meta (medium)
  • Find a String Containing Another - Meta (medium)
  • Solve Subarray Sum and Local Minimum - Meta (hard)
  • Validate abbreviations and brackets - Meta (medium)
Meta logo
Meta
Feb 28, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
2
0

You are working with an unknown language that uses a custom alphabetical order, such as ['a', 'd', 'c', 'b', ...].

Implement the following:

  1. Check sorted order : Given a custom alphabet order and an array of strings, determine whether the strings are sorted in nondecreasing lexicographic order under that alphabet.
  2. Follow-up : Given an array of strings that is already sorted according to an unknown custom alphabet, infer one possible alphabet order that is consistent with the given list. If no valid order exists, return that it is impossible.

Assumptions:

  • All strings consist of lowercase letters.
  • Lexicographic comparison is based on the first differing character.
  • If one word is a prefix of another, the shorter word must come first.
  • In the follow-up, if multiple valid alphabet orders exist, returning any one of them is acceptable.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Meta•More Software Engineer•Meta Software Engineer•Meta Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.