Skip to content

Instantly share code, notes, and snippets.

@JulianAR97
JulianAR97 / App.svelte
Created June 14, 2021 22:03
Svelte Userbase Integration
<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
@JulianAR97
JulianAR97 / greaterThanTree.js
Created June 8, 2021 02:23
Greater Than Tree Solution
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;
}