Analysis:
Use custom TreeNode with
leftcntandcntattributes.leftcntdepict the numbers smaller than the current node.cntrepresent the nodes has the same value before current node
Time Complexity:
- O(n)
Space Complexity:
- O(n)
Code
1 | class TreeNode(object): |