Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 91e60a3

Browse files
committed
[Have made changes to correct the test case]: Implemented the program to check if string is acronym of words or not.
1 parent 8514261 commit 91e60a3

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

.idea/workspace.xml

Lines changed: 12 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/com/raj/CheckIfStringIsAnAcronymOfWords.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
public class CheckIfStringIsAnAcronymOfWords {
4242
public static void main(String[] args) {
4343
// Initialization.
44-
List<String> words = new ArrayList<>(Arrays.asList("alice", "bob", "charlie"));
45-
String s = "abc";
44+
List<String> words = new ArrayList<>(Arrays.asList("afqcpzsx", "icenu"));
45+
String s = "yi";
4646
boolean isValid = false;
4747

4848
// Logic.
@@ -51,8 +51,11 @@ public static void main(String[] args) {
5151
if (words.get(i).charAt(0) != s.charAt(i)) {
5252
break;
5353
}
54+
if (i == words.size() - 1) {
55+
isValid = true;
56+
break;
57+
}
5458
}
55-
isValid = true;
5659
}
5760

5861
// Display the result.

0 commit comments

Comments
 (0)