Facebook Interview Class Design Question
Anonymous User
932
Apr 16, 2020
Apr 16, 2020

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 (4)