Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/EASY.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Total: 36 problems solved
| 2315 | [Count Asterisks](https://leetcode.com/problems/count-asterisks/) | [CountAsterisks2315.java](../src/main/java/com/leetcode/easy/CountAsterisks2315.java) | [CountAsterisks2315Test.java](../src/test/java/com/leetcode/easy/CountAsterisks2315Test.java) |
| 2469 | [Convert the Temperature](https://leetcode.com/problems/convert-the-temperature/) | [ConvertTheTemperature2469.java](../src/main/java/com/leetcode/easy/ConvertTheTemperature2469.java) | [ConvertTheTemperature2469Test.java](../src/test/java/com/leetcode/easy/ConvertTheTemperature2469Test.java) |
| 2798 | [Number of Employees Who Met the Target](https://leetcode.com/problems/number-of-employees-who-met-the-target/) | [NumberOfEmployeesWhoMetTheTarget2798.java](../src/main/java/com/leetcode/easy/NumberOfEmployeesWhoMetTheTarget2798.java) | [NumberOfEmployeesWhoMetTheTarget2798Test.java](../src/test/java/com/leetcode/easy/NumberOfEmployeesWhoMetTheTarget2798Test.java) |
| 2828 | [Check If A String Is An Acronym Of Words](https://leetcode.com/problems/check-if-a-string-is-an-acronym-of-words/) | [CheckIfAStringIsAnAcronymOfWords2828.java](../src/main/java/com/leetcode/easy/CheckIfAStringIsAnAcronymOfWords2828.java) | |
| 2828 | [Check If A String Is An Acronym Of Words](https://leetcode.com/problems/check-if-a-string-is-an-acronym-of-words/) | [CheckIfAStringIsAnAcronymOfWords2828.java](../src/main/java/com/leetcode/easy/CheckIfAStringIsAnAcronymOfWords2828.java) | [CheckIfAStringIsAnAcronymOfWords2828Test.java](../src/test/java/com/leetcode/easy/CheckIfAStringIsAnAcronymOfWords2828Test.java) |
| 3289 | [The Two Sneaky Numbers of Digitville](https://leetcode.com/problems/the-two-sneaky-numbers-of-digitville/) | [TheTwoSneakyNumbersOfDigitville3289.java](../src/main/java/com/leetcode/easy/TheTwoSneakyNumbersOfDigitville3289.java) | [TheTwoSneakyNumbersOfDigitville3289Test.java](../src/test/java/com/leetcode/easy/TheTwoSneakyNumbersOfDigitville3289Test.java) |

---
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.leetcode.easy;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.Arrays;
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class CheckIfAStringIsAnAcronymOfWords2828Test {
private CheckIfAStringIsAnAcronymOfWords2828 solution;

@BeforeEach
void setUp() {
solution = new CheckIfAStringIsAnAcronymOfWords2828();
}

@Test
void testIsAcronym_Example1_ValidAcronym() {
// Input: words = ["alice","bob","charlie"], s = "abc"
// First characters: 'a', 'b', 'c' -> "abc"
List<String> words = Arrays.asList("alice", "bob", "charlie");
String s = "abc";

assertTrue(solution.isAcronym(words, s));
}

@Test
void testIsAcronym_Example2_LengthMismatch() {
// Input: words = ["an","apple"], s = "a"
// First characters: 'a', 'a' -> "aa" (length 2)
// s = "a" (length 1), so cannot match
List<String> words = Arrays.asList("an", "apple");
String s = "a";

assertFalse(solution.isAcronym(words, s));
}

@Test
void testIsAcronym_Example3_LongAcronym() {
// Input: words = ["never","gonna","give","up","on","you"], s = "ngguoy"
// First characters: 'n', 'g', 'g', 'u', 'o', 'y' -> "ngguoy"
List<String> words = Arrays.asList("never", "gonna", "give", "up", "on", "you");
String s = "ngguoy";

assertTrue(solution.isAcronym(words, s));
}
}
Loading