Common Interview Questions | Glassdoor

Common Interview Questions


interview questions shared by candidates

Common Interview Questions

Sort: RelevancePopular Date

find lowest common ancestor of 2 nodes in a binary tree

3 Answers

I tried a complicated recursive methods and got stuck. If there is no restriction, we actually could use an hash map to store tree nodes while tracing up the parent nodes of the given nodes. if a common node is found to be parent of the given 2 nodes then print it out

Node lowestCommonAncestor(Node root, Node a, Node b) { if (root.contains(a) && root.contains(b)) { if (root.left != null && root.left.contains(a) && root.left.contains(b)) return lowestCommonAncestor(root.left, a, b); else if (root.right != null && root.right.contains(a) && root.right.contains(b)) return lowestCommonAncestor(root.right, a, b); else return root; } else return null; } boolean contains(Node root, Node x) { if (root == null || x == null) return false; // not needed. Defensive coding if (root == x) return true; if (root.left != null and root.left.contains(x)) return true; if (root.right != null and root.right.contains(x)) return true; return false; }

int lowestCommonAncestor(Node node, int value1, int value2){ if(node == null) return -1; if(value1 > && value2 > return lowestCommonAncestor(node.right, value1, value2); else if(value1 < && value2 < return lowestCommonAncestor(node.left, value1, value2); else return; }

How would you handle an irate customer?

1 Answer

They were all straightforward and not difficult to answer.

1 Answer

how would sale carwash coupons or services to potential customer

1 Answer

Sell me this pen? And what would you do if you caught your employees stealing( they literally think everyone is stealing from them). Reality it's a generic store manager interview substitute pawn for all the normal questions. I think they literally take it from googles best interview questions.

1 Answer

are you married or single

5 Answers

"If you could be any part in a garden salad, what ingredient would you be?"

1 Answer

What is a Common Table Expression?

1 Answer

Describe a difficult customer and how you handled the situation

110 of 11 Interview Questions