Monday, February 15, 2021

Leetcode Everyday: 1678. Goal Parser Interpretation. Easy

public class Solution {
    public string Interpret(string command) {
        var replaceWith = new Dictionary<string, string>() 
        {
            ["()"] = "o",
            ["(al)"] = "al"
        };
        foreach (var (key, value) in replaceWith) {
            command = command.Replace(key, value);
        }
        return command;
    }
}
Source: https://leetcode.com/problems/goal-parser-interpretation/submissions/

No comments:

Post a Comment