Code Lab

Режим собеседования. Таймер на 10 мин, без подсказок и автодополнения

First non-repeating character

СредняяMap и Set10 мин

Write a function firstUniqueChar(text) that returns the first character of the string text that appears in it exactly once. If there is no such character, return null.

  • "First" means the leftmost in text: in 'swiss' the answer is 'w'.
  • Letter case matters: 'a' and 'A' are different characters.
  • Every character counts, also spaces, digits and punctuation.
  • An emoji such as 🐞 is one character. Return it whole, not half of it.
  • An empty string gives null.

Примеры

firstUniqueChar('swiss')

Вернёт 'w'

firstUniqueChar('aabb')

Вернёт null

firstUniqueChar('aA')

Вернёт 'a'

Источник

Загружаем редактор...
  1. Входные данныеfirstUniqueChar('swiss')
    Ожидалось'w'
  2. Входные данныеfirstUniqueChar('aabb')
    Ожидалосьnull
  3. Входные данныеfirstUniqueChar('aA')
    Ожидалось'a'

Скрытые тесты запускаются по Submit