Skip to content

Instantly share code, notes, and snippets.

@primaryobjects
Created March 11, 2025 20:40
Show Gist options
  • Save primaryobjects/b883bfd33a86f5e29f28d3a78afc5a4f to your computer and use it in GitHub Desktop.
Save primaryobjects/b883bfd33a86f5e29f28d3a78afc5a4f to your computer and use it in GitHub Desktop.
function isAcronym(words: string[], s: string): boolean {
let result = true;
let offset = 0;
for (let i=0; i<words.length; i++) {
const word = words[i];
const letter = word[0];
if (s[offset++] !== letter) {
result = false;
break;
}
}
// Verify the result is true and no leftover letters in the acronym 's'.
return result && offset === s.length;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment