This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
let username, password | |
// will be set by userbase | |
let userObj = null | |
const userbase = window.userbase | |
// Userbase initializer | |
let authProm = userbase.init({appId: 'your appId from Userbase'}) | |
.then(({user}) => userObj = user) | |
// Very simple authentication functions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let sum = 0 // sum will be added to all 'less than' nodes | |
const convertBST = (root) => { | |
if (root == null) return; | |
convertBST(root.right); // traverse right | |
sum += root.val; // add root value to 'global' sum | |
root.val = sum; // new value becomes sum of all values that have already been seen | |
convertBST(root.left) // traverse left | |
return root; | |
} |