Published:
Updated:

https://leetcode.com/problems/goal-parser-interpretation/


Solution

class Solution {
    static String interpret(String command) {
        return command.replaceAll("\\(\\)", "o").replaceAll("\\(al\\)", "al");
    }

    public static void main(String[] args) {
        System.out.println(interpret("G()(al)"));
        System.out.print(interpret("G()()()()(al)"));
    }
}

Leave a comment