Solve the skyline problem
Anónimo
For 0sum triplet : function lca(root, a, b){ var res = null; (function(subroot){ var ret = 0; if(subroot == a) ret += 1; if(subroot == b) ret += 2; // a, b can be the same // lca can be either a or b as well if( ret == 3 ) { res = subroot; return 0; } if(subroot.left != null){ ret += arguments.callee(subroot.left); } if(subroot.right != null){ ret += arguments.callee(subroot.right); } if (ret === 3) { res = subroot; return 0; } return ret; })(root); return res; }