Given an array of strings words and a string s, determine if s is an acronym of words.
The string s is considered an acronym of words if it can be formed by concatenating the first character of each string in words in order. For example, “ab” can be formed from [“apple”, “banana”], but it can’t be formed from [“bear”, “aardvark”].
Return true if s is an acronym of words, and false otherwise.
Example 1:
1 | Input: words = ["alice","bob","charlie"], s = "abc" |
Example 2:
1 | Input: words = ["an","apple"], s = "a" |
Example 3:
1 | Input: words = ["never","gonna","give","up","on","you"], s = "ngguoy" |
Constraints:
1 | 1 <= words.length <= 100 |
Approach
1 | Check if the first char of every string in the array is equal to each char in the acronym string. |
Algorithm
1 | Go through the list and compare each char. |
Implementation
1 | bool isAcronym(char ** words, int wordsSize, char * s){ |