JavaScript simple solution


  • 0
    G
    var convertBST = function(root) {
      var temp = 0
      root && find(root)
      return root
    
      function find(root) {
        root.right && find(root.right)
        root.val += temp
        temp = root.val
        root.left && find(root.left)
      }
    };
    

Log in to reply
 

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