About
Register
Login
People
Trending
Discover
🏎️ Fast
What mistake have you learned most from?
5y, 4d
14 replies ¬
🌊 Zero Two
this feels like an interview question lol
5y, 4d
8 replies
Ice
given 2 nodes on a binary tree, return the lowest common ancestor in O(N) time
5y, 4d
5 replies
Login
or
register
your account to reply
🏎️ Fast
I would tell you, but no markdown support on here...
5y, 4d
1 reply
Ice
hah no worries. I got the solution during my last interviewing circuit
5y, 4d
reply
🌊 Zero Two
take one node, go up to root, take the other node go up to root or until u hit one u already seen.
5y, 4d
2 replies
🏎️ Fast
you're hired!
5y, 4d
reply
Ice
true, but only if child nodes have references to parent nodes. otherwise you'd need a top-down recursive approach where you return if the current node is the one of the child nodes in the callback
5y, 4d
reply