---
# System prepended metadata

title: LC 2828. Check if a String Is an Acronym of Words
tags: [easy, leedcode, python]

---

# LC 2828. Check if a String Is an Acronym of Words

### [Problem link](https://leetcode.com/problems/check-if-a-string-is-an-acronym-of-words/)

###### tags: `leedcode` `python` `easy`

Given an array of strings <code>words</code> and a string <code>s</code>, determine if <code>s</code> is an  **acronym**  of words.

The string <code>s</code> is considered an acronym of <code>words</code> if it can be formed by concatenating the  **first**  character of each string in <code>words</code>  **in order** . For example, <code>"ab"</code> can be formed from <code>["apple", "banana"]</code>, but it can't be formed from <code>["bear", "aardvark"]</code>.

Return <code>true</code> if <code>s</code> is an acronym of <code>words</code>, and <code>false</code> otherwise. 

**Example 1:** 

```
Input: words = ["alice","bob","charlie"], s = "abc"
Output: true
Explanation: The first character in the words "alice", "bob", and "charlie" are 'a', 'b', and 'c', respectively. Hence, s = "abc" is the acronym. 
```

**Example 2:** 

```
Input: words = ["an","apple"], s = "a"
Output: false
Explanation: The first character in the words "an" and "apple" are 'a' and 'a', respectively. 
The acronym formed by concatenating these characters is "aa". 
Hence, s = "a" is not the acronym.
```

**Example 3:** 

```
Input: words = ["never","gonna","give","up","on","you"], s = "ngguoy"
Output: true
Explanation: By concatenating the first character of the words in the array, we get the string "ngguoy". 
Hence, s = "ngguoy" is the acronym.
```

 **Constraints:** 

- <code>1 <= words.length <= 100</code>
- <code>1 <= words[i].length <= 10</code>
- <code>1 <= s.length <= 100</code>
- <code>words[i]</code> and <code>s</code> consist of lowercase English letters.

## Solution 1
```python=
class Solution:
    def isAcronym(self, words: List[str], s: str) -> bool:
        res = []
        for word in words:
            res.append(word[0])
            
        return ''.join(res) == s
```

>### Complexity
>n = words.length
>|             | Time Complexity | Space Complexity |
>| ----------- | --------------- | ---------------- |
>| Solution 1  | O(n)            | O(n)             |

## Note
x
