Square: Shortest Unique Prefix

CppCodingZen
3 min readSep 6, 2020

Problem:

Given a list of words, return the shortest unique prefix of each word. For example, given the list:

dog 
cat
apple
apricot
fist

Return the list:

d
c
app
apr
f

Simple Hash-based Solution:

--

--

CppCodingZen

Solutions to programming interview questions at some of the top companies in the world: cppcodingzen.com