Skip to content

Commit

Permalink
feat(leetcode): add No.2828
Browse files Browse the repository at this point in the history
  • Loading branch information
mickey0524 committed Nov 14, 2023
1 parent e6f2771 commit 899283f
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions 2828.Check-if-a-string-is-an-acronym-of-words.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// https://leetcode.com/problems/check-if-a-string-is-an-acronym-of-words/description/
// algorithms
// Easy (83%)
// Total Accepted: 57.3K
// Total Submissions: 69K


class Solution {

public boolean isAcronym(List<String> words, String s) {
int wordSize = words.size();
int sLen = s.length();

if (wordSize != sLen) {
return false;
}

int idx = 0;
for (String w : words) {
if (w.charAt(0) != s.charAt(idx)) {
return false;
}

idx++;
}

return true;
}

}

0 comments on commit 899283f

Please sign in to comment.