Loading...
Engaged Employer
Write code for a binary tree who find the lowest node and bubbles it up to the root.
Anonymous
what do you mean by bubble up!?
private static Node root; private static Node temp; private static int least = Integer.MAX_VALUE; private static Node swapLeast(Node r) { if (r.val < least) { least = r.val; temp = r; } if (r.left != null) swapLeast(r.left); if (r.right != null) swapLeast(r.right); temp.val = root.val; root.val = least; return root; }
Check out your Company Bowl for anonymous work chats.
Get actionable career advice tailored to you by joining more bowls.
Stay ahead in opportunities and insider tips by following your dream companies.
Get personalized job recommendations and updates by starting your searches.