```python
[Read More]
241. Different Ways to Add Parentheses
```python class Solution: def diffWaysToCompute(self, expression: str) -> List[int]: “"”tc O()??? main idea: devide & conquer + memoization 1. each time encounter a operator, devide into left and right part, do recursion to get a list of integer, 2. iterate through left and right make new substring with different priority...
[Read More]
1370. Increasing Decreasing String
TLE ```python class Solution: def sortString(self, s: str) -> str: “”” tc O(N) sc O(N) 1. cnt ocurrance for each c in s 2. a-z append to res and z-a append to res 3. keep doing step2 until res reaches len of s “”” d = {} for c in...
[Read More]
1249. Minimum Remove to Make Valid Parentheses
Stack Solution ```python class Solution: def minRemoveToMakeValid(self, s: str) -> str: “”” tc O(N) sc O(N) main idea: to make valid + since we can only remove => need to count to keep current substring balanced => how to minimize remove steps =>greedy ? XXX use stack to track open...
[Read More]
678. Valid Parenthesis String
```python class Solution: def checkValidString(self, s: str) -> bool: “”” main idea: check open parathesis – to make valid parathesis, we need to make sure in the end there are 0 open parethesis but in the mean time of looping through s, we need to make sure current substring has...
[Read More]