Shortest Unique Prefix

Given an array of words words, find the shortest prefix of each word that distinguishes it from every other word. Return the prefixes in the original input order.

A prefix is unique if exactly one ...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: