二叉搜索树中的众数
思路:双指针一个cur记录当前结点,一个pre记录之前结点
二叉搜索树一定是中序遍历,只有中序遍历元素可以保持有序
代码技巧:判断count和max_count的大小
if self.count == self.max_count:
self.result.append(root.val)
elif self.count > self.max_count:
self.max_count = self.count
self.result = []
self.result.append(root.val)
要在最大计数更新之后开始把result置空