Режим собеседования. Таймер на 10 мин, без подсказок и автодополнения
Anagram check
СредняяСтроки10 мин
Write a function isAnagram(a, b) that returns true when the string b is an anagram of a: it has exactly the same characters, the same number of times each, in any order. Otherwise return false.
- Letter case does not matter:
'Listen'and'Silent'are anagrams. - Spaces do not count:
'dormitory'and'dirty room'are anagrams. - Every other character counts: digits, punctuation, letters such as
é, and emoji. - The number of times matters:
'aab'and'abb'are not anagrams, even though they use the same letters. - Two empty strings are anagrams.
- A string can be long, up to 300 000 characters. Your code must finish in time.
Примеры
isAnagram('Listen', 'Silent')Вернёт true
isAnagram('dormitory', 'dirty room')Вернёт true
isAnagram('aab', 'abb')Вернёт false
Загружаем редактор...
- Входные данные
isAnagram('Listen', 'Silent')Ожидалосьtrue - Входные данные
isAnagram('dormitory', 'dirty room')Ожидалосьtrue - Входные данные
isAnagram('aab', 'abb')Ожидалосьfalse
Скрытые тесты запускаются по Submit