Skip to content

Instantly share code, notes, and snippets.

@btsheehy
btsheehy / getLowestCommonDenominator.js
Created November 18, 2020 18:35
getLowestCommonDenominator challenge
// write a function getLowestCommonAncestor(root, id1, id2)
// it should return the lowest common ancestor
// getLowestCommonAncestor(root, 13, 13) === 13
// getLowestCommonAncestor(root, 14, 14) === 14
// getLowestCommonAncestor(root, 13, 14) === 6
// getLowestCommonAncestor(root, 12, 14) === 2
// getLowestCommonAncestor(root, 7, 14) === 0
const root = {
id: 0,