Facebook Interview Class Design Question

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2020-04-16Added By Anonymous
Source: Link

Company: Meta (Facebook)
Role: unknown
Interview Stage: Phone Screen
Location: unknown
Year: unknown

Original Post Content:

Design a data structure to store a set of possibly nested placeholders organized by language. Using that data structure, write a function which given an input string with placeholders can return the expanded string, localized and falling back to English if a translation of the placeholder does not exist.

set('1234', 'en', 'Hello world')
set('1234', 'es', 'Hola mundo')

expand('{{dc.1234}}', 'en')
Hello world

expand('{{dc.1234}}', 'es')
Hola mundo

set('2345', 'en', '{{dc.1234}}, I'm alive!')

Note : I will appreciate if u can tell me your approach on this question. It was a 30 min interview

Comments