Skip to content

Commit a068076

Browse files
committed
Add solution #1678
1 parent c9fee53 commit a068076

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 1,468 LeetCode solutions in JavaScript
1+
# 1,469 LeetCode solutions in JavaScript
22

33
[https://leetcodejavascript.com](https://leetcodejavascript.com)
44

@@ -1292,6 +1292,7 @@
12921292
1673|[Find the Most Competitive Subsequence](./solutions/1673-find-the-most-competitive-subsequence.js)|Medium|
12931293
1674|[Minimum Moves to Make Array Complementary](./solutions/1674-minimum-moves-to-make-array-complementary.js)|Medium|
12941294
1675|[Minimize Deviation in Array](./solutions/1675-minimize-deviation-in-array.js)|Hard|
1295+
1678|[Goal Parser Interpretation](./solutions/1678-goal-parser-interpretation.js)|Easy|
12951296
1679|[Max Number of K-Sum Pairs](./solutions/1679-max-number-of-k-sum-pairs.js)|Medium|
12961297
1716|[Calculate Money in Leetcode Bank](./solutions/1716-calculate-money-in-leetcode-bank.js)|Easy|
12971298
1718|[Construct the Lexicographically Largest Valid Sequence](./solutions/1718-construct-the-lexicographically-largest-valid-sequence.js)|Medium|
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* 1678. Goal Parser Interpretation
3+
* https://leetcode.com/problems/goal-parser-interpretation/
4+
* Difficulty: Easy
5+
*
6+
* You own a Goal Parser that can interpret a string command. The command consists of an alphabet
7+
* of "G", "()" and/or "(al)" in some order. The Goal Parser will interpret "G" as the string
8+
* "G", "()" as the string "o", and "(al)" as the string "al". The interpreted strings are then
9+
* concatenated in the original order.
10+
*
11+
* Given the string command, return the Goal Parser's interpretation of command.
12+
*/
13+
14+
/**
15+
* @param {string} command
16+
* @return {string}
17+
*/
18+
var interpret = function(command) {
19+
let result = '';
20+
21+
for (let i = 0; i < command.length; i++) {
22+
if (command[i] === 'G') {
23+
result += 'G';
24+
} else if (command[i] === '(' && command[i + 1] === ')') {
25+
result += 'o';
26+
i++;
27+
} else {
28+
result += 'al';
29+
i += 3;
30+
}
31+
}
32+
33+
return result;
34+
};

0 commit comments

Comments
 (0)