File tree 2 files changed +36
-1
lines changed
2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change 1
- # 1,468 LeetCode solutions in JavaScript
1
+ # 1,469 LeetCode solutions in JavaScript
2
2
3
3
[ https://leetcodejavascript.com ] ( https://leetcodejavascript.com )
4
4
1292
1292
1673|[ Find the Most Competitive Subsequence] ( ./solutions/1673-find-the-most-competitive-subsequence.js ) |Medium|
1293
1293
1674|[ Minimum Moves to Make Array Complementary] ( ./solutions/1674-minimum-moves-to-make-array-complementary.js ) |Medium|
1294
1294
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|
1295
1296
1679|[ Max Number of K-Sum Pairs] ( ./solutions/1679-max-number-of-k-sum-pairs.js ) |Medium|
1296
1297
1716|[ Calculate Money in Leetcode Bank] ( ./solutions/1716-calculate-money-in-leetcode-bank.js ) |Easy|
1297
1298
1718|[ Construct the Lexicographically Largest Valid Sequence] ( ./solutions/1718-construct-the-lexicographically-largest-valid-sequence.js ) |Medium|
Original file line number Diff line number Diff line change
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
+ } ;
You can’t perform that action at this time.
0 commit comments