Python Solution


  • 0
    class Solution(object):
        def findSecondMinimumValue(self, root):
            self.ans = 0xffffffff
            def dfs(r):
                if not r:
                    return
                if r.val == root.val:
                    dfs(r.left)
                    dfs(r.right)
                else:
                    self.ans = min(r.val, self.ans)
            dfs(root)
            return self.ans if self.ans != 0xffffffff else -1
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.