Skip to main content
Back to problems
#2828
Easy Algorithms

Check if a string is an acronym of words

Array String
82.9% acceptance
Feb 25, 2026
369
13
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.

Solution

Rust
Time O(n)
Space O(1)
LeetCode
solution.rs
impl Solution {
  pub fn is_acronym(words: Vec<String>, s: String) -> bool {
    s.len() == words.len() && words.iter().zip(s.chars()).all(|(w, c)| w.starts_with(c))
  }
}