You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
time O(2^n (n is the number of operators in input)) space O(n)
The idea is to apply divide-and-conquer thinking to recursively solve the problem. The key point here is to look for operators.
We iterate through the string and for each operator we find, we know that its left and right strings are its operands. So we could
recursively call the function itself and pass these two substrings as its new parameters.
We also optimized the recursion with memoization using hashmap.