Pergunta de entrevista da empresa Meta

first task was very easy usage of data structure, second one was about precalculation using the hashmap