Skip to content

Commit 3ca4225

Browse files
solves goal parser implemetation
1 parent 52b74b8 commit 3ca4225

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@
413413
| 1662 | [Check If Two String Arrays are Equivalent](https://leetcode.com/problems/check-if-two-string-arrays-are-equivalent) | [![Java](assets/java.png)](src/CheckIfTwoStringArraysAreEquivalent.java) | |
414414
| 1668 | [Maximum Repeating Substring](https://leetcode.com/problems/maximum-repeating-substring) | [![Java](assets/java.png)](src/MaximumRepeatingSubString.java) | |
415415
| 1672 | [Richest Customer Wealth](https://leetcode.com/problems/richest-customer-wealth) | [![Java](assets/java.png)](src/RichestCustomerWealth.java) | |
416-
| 1678 | [Goal Parser Interpretation](https://leetcode.com/problems/goal-parser-interpretation) | | |
416+
| 1678 | [Goal Parser Interpretation](https://leetcode.com/problems/goal-parser-interpretation) | [![Java](assets/java.png)](src/GoalParserInterpretation.java) | |
417417
| 1684 | [Count the Number of Consistent Strings](https://leetcode.com/problems/count-the-number-of-consistent-strings) | | |
418418
| 1688 | [Count of Matches in Tournament](https://leetcode.com/problems/count-of-matches-in-tournament) | | |
419419
| 1694 | [Reformat Phone Number](https://leetcode.com/problems/reformat-phone-number) | | |

src/GoalParserInterpretation.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
public class GoalParserInterpretation {
2+
public String interpret(String command) {
3+
final StringBuilder result = new StringBuilder();
4+
for (int index = 0 ; index < command.length() ; ) {
5+
if (command.charAt(index) == 'G') {
6+
result.append('G');
7+
index++;
8+
} else if (command.charAt(index + 1) == ')') {
9+
result.append('o');
10+
index += 2;
11+
} else {
12+
result.append("al");
13+
index += 4;
14+
}
15+
}
16+
return result.toString();
17+
}
18+
}

0 commit comments

Comments
 (0)