Goal Parser Interpretation — LeetCode

Here’s the question. It’s a LeetCode easy:

LeetCode Question #1678

There are a few ways you can solve this. You can do it in 23 lines with a loop, or you can use a simple Python function to solve in one line.

Here is my solution that is faster than 99.94% of 13,000 submissions:

https://carbon.now.sh

In the above solution, we iterate from 0 to the length of the command str. We append values to a string as well as iterate depending on what the current character is. There is also a one-line python solution for this though.

Here is the submission report for the 23 line solution above:

Pretty Quick

As always, my source code is located here and my social links are located here.