← All solutions

Check if a String Is an Acronym of Words

June 02, 2025 • Go •array, string • easy

Problem

  • Return true if s is an acronym of words, and false otherwise.

Go Solution

func isAcronym(words []string, s string) bool {
    if len(words) != len(s) {
        return false
    }

    for i := range words {
        if words[i][0] != s[i] {
            return false
        }
    }
    return true
}
LeetCode Problem Link