Finite-State-Machines (FSM) and avoidance of string manipulation via lazy appending
Latest problem from Leetcode required a combination of FSM and avoidance of string manipulation (in C#, expensive). Here it is: Evaluate the Bracket Pairs of a String - LeetCode 1807. Evaluate the Bracket Pairs of a String Medium 13 1 Add to List Share You are given a string s that contains some bracket pairs, with each pair containing a non-empty key. For example, in the string "(name)is(age)yearsold" , there are two bracket pairs that contain the keys "name" and "age" . You know the values of a wide range of keys. This is represented by a 2D string array knowledge where each knowledge[i] = [key i , value i ] indicates that key key i has a value of value i . You are tasked to evaluate all of the bracket pairs. When you evaluate a bracket pair that contains some key key i , you will: Replace key i and the bracket pair with the key's corresponding...