1597. Build Binary Expression Tree From Infix Expression

Similar to LC772 Basic Calculator III ```python Definition for a binary tree node. class Node(object): def init(self, val=” “, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def expTree(self, s: str) -> ‘Node’: “”” main idea: [two stacks] use two stack to store operators and... [Read More]
Tags: String Tree

1569. Number of Ways to Reorder Array to Get Same BST

```python class Solution: def numOfWays(self, nums: List[int]) -> int: “”” main idea: with fixed root node, we can get list of left subtree and right subtree; we just need to keep both subtree’s relative position in order - using Pasca; triangle ==> note, given one sequence, we can get a... [Read More]
Tags: DP