Skip to main content
Back to problems
#1678
Easy Algorithms

Goal parser interpretation

String
88.0% acceptance
Feb 25, 2026
1672
93
You own a Goal Parser that can interpret a string command. The command consists of "G", "()" and/or "(al)" in some order. "G" -> "G", "()" -> "o", "(al)" -> "al". Return the Goal Parser's interpretation of command.

Solution

Rust
Time O(1)
Space O(1)
LeetCode
solution.rs
impl Solution {
  pub fn interpret(command: String) -> String {
    command.replace("()", "o").replace("(al)", "al")
  }
}