Режим собеседования. Таймер на 7 мин, без подсказок и автодополнения
Полки с Ремарком
ЛёгкаяMap и Set7 мин
В библиотеке два словаря. В shelves ключ это номер полки, значение массив книг на ней. В authors ключ это название книги, значение её автор.
Напиши функцию shelvesWithAuthor(shelves, authors, author). Она возвращает массив полок, на которых стоит хотя бы одна книга этого автора. Порядок полок любой.
Примеры
shelvesWithAuthor({ 1: ['Three Comrades'], 2: ['The Idiot'], 3: ['Arch of Triumph', 'Three Comrades'] }, { 'Three Comrades': 'Remarque', 'The Idiot': 'Dostoevsky', 'Arch of Triumph': 'Remarque' }, 'Remarque')Вернёт [ '1', '3' ]
shelvesWithAuthor({ 1: ['The Idiot'] }, { 'The Idiot': 'Dostoevsky' }, 'Remarque')Вернёт []
Спрашивали в T-Bank · Источник
Загружаем редактор...
- Входные данные
shelvesWithAuthor({ '1': [ 'Three Comrades' ], '2': [ 'The Idiot' ], '3': [ 'Arch of Triumph', 'Three Comrades' ] }, { 'Three Comrades': 'Remarque', 'Arch of Triumph': 'Remarque', 'All Quiet on the Western Front': 'Remarque', 'The Idiot': 'Dostoevsky', 'The Master and Margarita': 'Bulgakov', 'Heart of a Dog': 'Bulgakov' }, 'Remarque')Ожидалось[ '1', '3' ] - Входные данные
shelvesWithAuthor({ '1': [ 'The Idiot' ] }, { 'Three Comrades': 'Remarque', 'Arch of Triumph': 'Remarque', 'All Quiet on the Western Front': 'Remarque', 'The Idiot': 'Dostoevsky', 'The Master and Margarita': 'Bulgakov', 'Heart of a Dog': 'Bulgakov' }, 'Remarque')Ожидалось[] - Входные данные
shelvesWithAuthor({ '1': [ 'Heart of a Dog', 'The Idiot' ], '2': [ 'Three Comrades' ], '3': [ 'The Master and Margarita' ] }, { 'Three Comrades': 'Remarque', 'Arch of Triumph': 'Remarque', 'All Quiet on the Western Front': 'Remarque', 'The Idiot': 'Dostoevsky', 'The Master and Margarita': 'Bulgakov', 'Heart of a Dog': 'Bulgakov' }, 'Bulgakov')Ожидалось[ '1', '3' ]
Скрытые тесты запускаются по Submit