Ctrl K

Code From First Letters

Easy
A team names its projects with short codes: it takes a multi-word title words and writes down the first letter of each word in a row. Given a string code, return True if it is exactly the code made of the first letters of words in their order, and False otherwise.
Example 1
words=["keep", "it", "simple"], code="kis" → True

The first letters are k, i and s, which spell "kis".

Example 2
words=["red", "orange"], code="ro" → True

The first letters r and o match the code.

Example 3
words=["sun", "sea"], code="s" → False

The first letters give "ss", not "s": each letter of the code must match exactly one word.

Constraints
  • 1 ≤ len(words) ≤ 100
  • 1 ≤ len(words[i]) ≤ 20
  • 1 ≤ len(code) ≤ 100
  • words[i] and code consist of lowercase English letters
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsTwo Words, Closest Apart EasyOne-Row Typing EasyDinner for Two EasyPhrases with Synonyms EasyWord from a License Plate Easy
loading Python…
Input
words=["keep", "it", "simple"], code="kis"
Expected
True

Run checks the first 3 tests in your browser. Submit checks all 130 tests on the server, hidden ones included.