I have been coding in Ruby for last 6 years and it is my strongest language by far. However, as I was preparing to interview at top tech companies, I faced a big question - which programming language should I use?
If you ask this question to your recruiter, they will likely say that the language doesn’t matter. But how true is that? I had doubts that the simplicity and almost english like syntax of Ruby would actually be confused by interviewers as pseudocode. I imagined interviewers like to see working code and not pseudocode. I was afraid my choice of Ruby would hurt my chances of getting in.
7 interviews and 3 offers (2 small 1 large company) later I’m convinced that choosing Ruby wasn’t such a bad decision after all. As long as you are an expert in one language, the choice of language shouldn’t be much of an impediment.
In this blog post I’ll share solutions for some frequently asked programming problems in Ruby. Ruby code samples for interviews are really sparse and websites like Leetcode, Geeks For Geeks tend to be heavier on Java and Python solutions. I was often stuck wondering how a problem could be implemented in Ruby efficiently. It is always good to have a reference solution to work from.
Here we go!
Trees and Tree Traversal Basics
Find if a tree is balanced
Common Ancestor of Nodes in a Tree
Max Depth of a Tree
Two Sum Problem
Find if any two numbers in an array sum to a target value