Monday, April 4, 2016

Ruby Interview Questions: Problem Walkthroughs

We've talked a bit about interviewing with Ruby and the basic tools of the game. In this article, we will consider some harder interview questions that ask us to apply some of the concepts we have learned thus far. The point here isn't just to learn how to implement the solutions to the problems, but the train of thought that leads to a solution.

The problem you are presented with while you stand nervously at the whiteboard (by the way, whiteboard coding sucks) might be very different from the stuff you've already seen, but if you truly understand the motivation behind the solutions, you'll be fine. Without further ado, let's look at our first problem.

Closest Ancestors

Here's the first problem:

Given two nodes within a binary tree, find their lowest common ancestor.

Where the lowest common ancestor is the first node (i.e. one with minimum distance) that both given nodes have in common as an ancestor. OK, let's think through this thing.

Continue reading %Ruby Interview Questions: Problem Walkthroughs%


by Dhaivat Pandya via SitePoint

No comments:

Post a Comment