Interview Questions: Types of Coding and Algorithm Questions

Part of a continuing series on Interviews and Interview Questions.

Today, we’re going to look at types of coding and algorithm questions. As discussed before, these can be divided up into ‘Problem Solving’ and ‘Knowledge’ questions.

As mentioned before, ‘Knowledge’ questions are very close to ‘human glossary’ questions. ‘What is the Big-O order of QuickSort? Average case? Worst case?’.

But there are some questions which straddle the line between knowledge and problem solving, answers that few but an expert in that topic would be able to exactly recall, like ‘what exactly happens between when you type google.com into your browser and the page appears?’, or ‘compare and contrast various sorting algorithms’.

For those questions, you have to be as widely read as possible, they tend to select for those who are more naturally inquisitive for things outside their specific area of expertise.

Now, for coding questions. There seem to be a few different types, which I’ll try to separate out by data structure[1]:

Arrays and Strings – Any data structure where any element is addressable in O(1) time, where elements are allocated together in memory.

Linked Lists, Stacks, and Queues – Data structures in linear form, where elements far away from the origin are O(N) difficult to access.

Trees – Data structures arranged in a tree form, with a clear root and directionality. Often sorted.

Graphs – Data structures with nodes and edges, where the edges can connect the nodes in arbitrary ways. Home to at least the plurality of the known NP-Complete problems. Note that Graph problems are a superset of the above.

Search and Optimization – Problems where you’re trying to find an optimal (or close to optimal) solution in a large multidimensional tensor or vector field. Many in this category are easily mappable to Graph Theory questions, but many are not, such as 3-D Protein Structure Prediction. Most interviews would likely not ask questions in this category, at least not very complex ones.

Machine Learning and Statistics – Somewhat related to Search and Optimization, problems dealing with how one trains a computer to solve a problem. Likely to become more and more important.

Hashes – Data structures where space is traded for speed. Generally assumed to have 0(1) insertion and retrieval

[1]Hat tip: developer.com

Interview Questions: Other

In previous posts, I’ve talked about the most important types of interview questions:

‘Behavioural’ questions ask ‘Describe a time when you encountered a problem like this’.

‘Situational’ questions ask ‘Given this situation, how would you solve it?’

‘Technical’ questions ask ‘Solve this defined problem for me.’

Today, I’ll cover some other types of questions that are known to not have much predictive power, but people still ask, either as an ice breaker, or because they have other reasons for asking these questions.

‘Ice Breaker’ questions ask ‘tell me a story about yourself, to help relax you.’

The purpose of ‘Ice Breaker’ questions is to get the conversational flow started. My personal favourite is ‘tell me about the project you’re most proud of’, because it will help to relax the candidate, and has the dual purpose of showing what a candidate is like when they’re excited about something.

Dumb’ questions ask things outside the normal boundaries of a standard interview.

From the link, examples might include “What kind of animal would you like to be?” or “What color best describes you?[1]” The ostensible purpose is to try to get beyond pre-programmed/rehearsed answers, looking for original thoughts. (I tend to prefer the ‘tell me what you’re most proud of’ type of question, as if you’re trying to knock a person off their rehearsed interview game, if they’re nervous, that might torpedo them, and you’re torpedoing them based on their interview skills, rather than actual skills. Better to choose a topic they know, and explore the limits of their thinking there.)

‘Illegal’ questions ask ‘I want to discriminate against you, in some illegal way’

Which questions are illegal will vary by jurisdiction, but generally include questions about things such as gender, age, marital status, religion, etc… Larger and governmental organizations tend to be better at not asking such questions, whether because of visibility or lawsuits. Knowing how to answer such questions can be tricky, because of the power differential between interviewer and interviewee, but especially because the organizations asking such questions may be hiring from a labour pool with few options.

‘Brainteaser’ or ‘Fermi‘ questions ask ‘How many piano tuners are there in New York’?

These questions are the stereotypical ‘Google interview’ question, which is funny, because Google no longer asks this type of question[2]. I happen to enjoy this type of question, and they can be very useful for back-of-the-envelope estimation, but don’t really have a useful place in job interviews.

Next time, we’ll go more in dept about specific types of technical questions. Stay tuned!

[1]My favourite story on this topic comes from the brainstorming exercise: “List all the things you could do with this brick.” People would come up with some small number of ideas (like <10) for how to use the brick. Then the facilitator would say something like: "List me all the ways that your wackiest friend could use this brick." Interestingly, this generally elicits many more ideas, as it removes some of the social opprobrium of being 'weird'. [2]cf. The British Empire no longer uses the ‘Imperial’ system.

Interview Questions: Technical

I’ve been writing about interview questions recently, most recently about ‘behavioural’ and ‘Situational’ questions. If you recall:

‘Behavioural’ questions ask ‘Describe a time when you encountered a problem like this’.

‘Situational’ questions ask ‘Given this situation, how would you solve it?’

‘Technical’ questions ask ‘Solve this defined problem for me.’

Today, I want to talk about ‘Technical’ questions. This includes two types:

‘Problem Solving’ questions, where the interviewer asks a technical question, and expects you to go through some process to solve it, similar in some way to what one would do in a job in the field.

‘Knowledge’ questions, where the interviewer asks specific questions about your field of study or work. For a programming job, they might be about memory management or data structures, for HR, they might be about what is legal or accepted practice in the jurisdiction in question, etc…

(Note that these generally don’t include questions about a resume, which I would group under the ‘Behavioural’ umbrella, as the interviewee is expected to tell a story about them.)

So what is an interviewer looking for in these questions?

For both of these questions, the interviewer is looking for command of the subject matter and problem solving ability. There’s a whole smear of possible questions between these two extremes. (‘What is an array’ to ‘Design LinkedIn’.)

For basic knowledge questions, it would probably suffice to re-read a textbook, or read (and understand!) a glossary of the topics one would be interviewed in.

For ‘Problem Solving’ questions, answers are generally more involved.

Generally, the interviewee is given a problem statement:

“Write a program which counts from 1 to 100, and outputs ‘Fizz’ when the number is a multiple of 3 and ‘Buzz’ when the number is a multiple of 5.”

This problem statement may or may not be well defined, so it falls on the interviewee to ask questions until it is adequately defined:

“Does it also print the number when it is a multiple of 3 or 5?” “Is proper syntax required?” “What language?”

(This also makes sure that the interviewer and the interviewee are on the same page.)

I like to draw a large diagram, and/or write down my assumptions in the upper-left corner when doing problems like this. Makes things explicit, people can see what you’re thinking.

One of my best bosses described his best programmer as ‘having a reason for every single line of code’. Talking through one’s code as it’s being written can help with this.

So:

Write down assumptions
Draw a big diagram
State the overall algorithm
Write down the solution, while talking about it
Think about corner cases, run an example through in your head.

Next time, we’ll talk some other types of questions, the kinds that are known to be not as predictive, but that interviewers still ask anyways, for various reasons. Stay tuned!

Interview Questions: Behavioural and Situational

Balancing factors. Persuading people.

Yesterday, I talked about three types of interview questions:

‘Behavioural’ questions ask ‘Describe a time when you encountered a problem like this’.

‘Situational’ questions ask ‘Given this situation, how would you solve it?’

‘Technical’ questions ask ‘Solve this defined problem for me.’

Today, I want to talk about the ‘Behavioural’ and ‘Situational’ questions.

First, how are these questions similar?

Both of these are asking you to describe a solution to a problem, a problem from a surprisingly narrow set of options.

Two (or more) factors that you need to balance[1].

Helping people work together when they disagree[2].

The two factors might be technical, like how you would balance ‘Reliability’ and ‘Performance’, or they might be human, like Legal disagreeing with Marketing. Already, you can see these options blurring together. Really, these questions are really asking about how you balance things and make decisions.

The follow-up is often ‘So, once you made this decision, how did you implement it? How did you convince people that this was the correct route?’

Balancing factors. Persuading people.

So, how are these questions different?

‘Behavioural’ questions ask ‘Describe a time when you encountered a problem like this’.

‘Situational’ questions ask ‘Given this situation, how would you solve it?’

‘Behavioural’ questions ask you to tell a story about something you’ve done. You want to look at all the things you’ve done (especially everything you put on your resume), and think about what kinds of problems each of them were. What factors were you balancing there? How did you persuade people to work together and solve the problem?

An interviewer may ask you this question from a number of different directions. It’s up to you to fit one of your stories into the narrative question they’ve created (or to rephrase it such that your story fits).

‘Situational’ questions ask you how you would solve a hypothetical situation. An interviewer would present a situation with multiple factors to balance, where people disagree, and you would need to mediate, make a decision, get buy-in for your decision.

In this case, it again can be calling on your experience, but be careful that you’re actually trying to solve the problem presented, not a different problem that you’ve encountered before[3].

Summing up:

‘Behavioural’ questions ask ‘Describe a time when you encountered a problem like this’.
‘Situational’ questions ask ‘Given this situation, how would you solve it?’

In both of these:

Balance factors.
Persuade people.

To answer:

‘Behavioural’, fit a story from your past into the question.
‘Situational’, put yourself into their story, and tell them how you would resolve it.

Next time, we’ll look at the more ‘technical’ side of interviews. Stay tuned!

[1]If you didn’t need to balance between two things, you would just choose one of them, and really, no decision is required.

[2]If people are in agreement, what decision is required?

[3]Or something from your childhood, natch.

Types of Interview Questions

Interviews. Almost everyone has been through one (or many), on one side of the table or the other[1].

Interestingly, research has been coming out saying that standardized procedures and checklists help in interviews as much as they checklists help in surgery.

To make a standardized procedure or checklist, it helps to have a list of the types of things one can ask a candidate.

A number of people have made lists of types of interview questions.

Google says: “We achieve that goal by doing what the science says: combining behavioral and situational structured interviews with assessments of cognitive ability, conscientiousness, and leadership.”

We’ll start with the first two (‘Leadership’ is best folded into these): Behavioural and Situational questions, generally considered to have the most predictive power at identifying better long-term work performance.

They’re actually pretty similar. In both, the interviewer is asking for a description of a solution to a problem (sometimes a tech problem, often a people or people/tech problem).

‘Behavioural’ questions ask ‘Describe a time when you encountered a problem like this’.

‘Situational’ questions ask ‘Given this situation, how would you solve it?’

Fundamentally, answers to questions like these (are supposed to) show how a candidate defines a problem, finds root cause, and solves it, within the constraints. (One could also see how quick a candidate is on their feet, or how rehearsed, by seeing the difference in speed to how they answer these two types of questions.)

Good sources for questions like these: Any project where you’ve had to solve a technical problem (tech), any project with multiple stakeholders (tech/people), working with another team (people).

How do you answer them? Probably the best way is to go back and think about each line item on your resume in detail (Most of the lines on your resume are problems you’ve solved, right?[2]). For each of those problems, you had to work with others, define a problem, come up with a solution, get buy-in, implement a solution, some, all, or some of none of these things.

‘Cognitive Ability’ in the strictest sense of the word is most often associated with standardized tests. When combined with ‘Conscientiousness’, you get technical problem solving questions, also known as ‘Coding Interview’ to its friends.

So, really, we’re left with three types of questions:

‘Behavioural’ questions ask ‘Describe a time when you encountered a problem like this’.

‘Situational’ questions ask ‘Given this situation, how would you solve it?’

‘Technical’ questions ask ‘Solve this defined problem for me.’

Next time, we’ll go a little more in depth into these categories. If you want a specific category first, comment below!

[1]This feels very adversarial. Also, very binary. Why are there only two sides to this table? (Somewhat related, in Europe, corporate-labour relations are a trinary system, with the government being an equal partner.)

[2]Much more powerful, this is.

Burning Man in Pictures XLVI: The Fearsome Medusa!

In our last installment, our intrepid heroes had met a number of new metallic friends, and gone on myriad adventures with Claude, the dragon.

Today, we follow their adventures confronting the FEARSOME MEDUSA!

Our heroes approach…:

Off in the dusty distance...THE MEDUSA!
Off in the dusty distance…THE MEDUSA!

…and are almost transfixed:

M and S are almost transfixed.
M and S are almost transfixed.

But then S notices that one of the snakes is made out of stone:

S points out some important things.  "I think that snake may be made of stone."
S points out some important things. “I think that snake may be made of stone.”

And receives a whispered quest[1]. “Follow the bird car to the birds’ nest[2]. There you shall find what I seek.”:

Following the drop/bird car to an even more dangerous place...
Following the drop/bird car to an even more dangerous place…

As part of the quest, our intrepid heroes consulted with law enforcement:

An indication of how safe Burning Man is.
An indication of how safe Burning Man is.

And received directions from the BLM:

The Bureau of Land Management, masters of Leave No Trace.
The Bureau of Land Management, masters of Leave No Trace.

To meet the Skull Truck, but that’s another story[3]:

The Skull Truck, off in the distance.
The Skull Truck, off in the distance.

Eventually, after fulfilling their quest for the Medusa, they received directions to their next destination, an important Phage Display:

An important Phage Display.
An important Phage Display.

Next time, we see what the phage may be displaying. Stay tuned!

[1]Comment if you want to hear this story!

[2]Off in the distance, you can see a multi-headed beast that even medusae fear…Comment if you want to hear the story!

[3]See [1] and [2].

Burning Man in Pictures XLV: Metallic Dragon Friends!

In our last installment, our plucky heroes had taken a sojourn amongst the growing coyotes. They then continued on until they saw a sign:

I would never use these words myself, but they seemed to enjoy them.
I would never use these words myself, but they seemed to enjoy them.

So many new friends! (Apparently, the real title is ‘Piazza D’Arte’.):

So many new friends!  (Or fiends?)
So many new friends! (Or fiends?)

This guy seemed a little…overly friendly. Luckily, he seemed to be constrained by the multicoloured shield[1].

This guy seemed a little...overly friendly.  Luckily, he seemed to be constrained by the multicoloured shield.
This guy seemed a little…overly friendly. Luckily, he seemed to be constrained by the multicoloured shield.

Next, M & S perused a strange bird/hammock structure, while the stork in the foreground made efforts to reduce workload in order to take some time off:

M & S peruse a strange bird/hammock(?), while the stork in the foreground is making efforts to take some time off.
M & S peruse a strange bird/hammock(?), while the stork in the foreground is making efforts to take some time off.

There was then this sign, introducing a Claude Dragon (not to be confused with Cloud, or Cloud Dragons):

Claude?  Does that mean...?
Claude? Does that mean…?

Claude entreated our intrepid heroes to enter, so that they could embark on an important quest. (This story shall be told at a later date…[2]):

Yes!  You can store many things in the Claude!
Yes! You can store many things in the Claude!

The good news was that this sentry was still there. They are always the first to leave, as they always know which way the wind is blowing:

"You're so vane, I bet you think this wind is about you..."
“You’re so vane, I bet you think this wind is about you…”

There was then this disturbing tableau, which is even more disturbing when you know the story behind why the being is caged, and why there is such a fearsome guardian[3]:

A disturbing tableau.  Even more disturbing if you knew the story behind why the cage and the guardian.
A disturbing tableau. Even more disturbing if you knew the story behind why the cage and the guardian.

Looking next door, our heroes saw this strange sight, recalling Phonecian legends[4]:

The jury is still out as to whether this is still a one-horsecar town.
The jury is still out as to whether this is still a one-horsecar town.

After many adventures, and many tearful goodbyes with their newfound metallic friends, our heroes embarked on the next leg of their journey, which they had spotted from their perch inside Claude. The FEARSOME MEDUSA!

Stay tuned!

[1]If you want to hear this story, comment below!

[2]This one, too!

[3]This one too, if you really, really want.

[4]This one sounds like fun!

Burning Man in Pictures XLIV: Dusty Exploration Amongst the Coyotes!

Today, M joins our heroes as they explore the dusty playa, meet coyotes, and see all manner of art.

In our last installment, our heroes experienced some of the most sublime nighttime fire art. Today, they explore dusty coyotes, and all manner of other odd installations.

But first, an installation which is an eloquent commentary on Burning Man culture (and probably culture in general):

I'm assuming they're talking about the bird.
I’m assuming they’re talking about the bird.

Moving on, our intrepid heroes came across an unusual garden. S ran inside, in the hopes…:

Is this what she thinks it is?
Is this what she thinks it is?

…that…yes! It was the garden where coyotes were grown! Long had she spoken to and tried to follow the way of Coyote, but now she had found the source! (Or rather, *a* source. Like Surprise Elementals, it is often difficult to figure out Coyote.):

It is! I am excited and terrified at the same time.
It is! I am excited and terrified at the same time.

Pausing for a few moments so that she could commune (and slightly alter the growing coyotes), we spent some time talking to this guy:

*All* cool coyotes wear shades.
*All* cool coyotes wear shades.

And learning about the importance of registering hugs[1][2]:

Registration is important.
Registration is important.

There was also an interesting barbecue/weather vane combination, which seemed to be an important part of the religious conversation on playa:

Religion often takes a different turn on playa.
Religion often takes a different turn on playa.

Next time, the Freak Show continues, with metallic dragons[3]!

[1]It is very important, especially with repeated hugging, to not let them get out of register. Els eyo uma yencounte rsomethin glik ethi s.

[2]Astute readers may notice the phone number in the picture.

[3]Metallic creatures of all types, even!

Burning Man in Pictures XLIII: Fire! (El Pulpo Mechanico, the Grasshopper, and Serpent Mother)

Today, some of the biggest and best fire installations the Burn has to offer!

In our last installment, our heroes took some time to reflect.

Today, we follow their adventures as they experience some of the best that playa has to offer in the way of fire art.

First, they met up with The Grasshopper and El Pulpo Mechanico. The Grasshopper they had not met before, but he seemed a friendly sort. El Pulpo was one of the mythical creatures of the Burn, visible from almost anywhere on playa, with a continual pied-piper-esque chase group of bicycles. Mythical for many reasons, not the least was the fact that there were so few seats that it was almost impossible to ever catch a ride.

This was one of our most magical moments. It’s difficult to express the fundamental beauty of flame effects set oh-so-perfectly to music, or just the feeling of the friendly competition. All I can do is show you some of the pictures.

Here we see a short video of the two of them having a musical chat:

They’re firey friends[1]!:

The Grasshopper and El Pulpo Mechanico, firey friends.
The Grasshopper and El Pulpo Mechanico, firey friends.

Here is S, amongst myriad onlookers, trying to get the perfect shot:

Amongst myriad onlookers, S tries to get the perfect shot.
Amongst myriad onlookers, S tries to get the perfect shot.

A few animated .gifs expressing the joy of the occasion:

*FOOM* *hee hee!*
*FOOM* *hee hee!*
*hee hee* *FOOMFOOM* *hee hee*
*hee hee* *FOOMFOOM* *hee hee*

And one capturing the fiery friendship between these two lovable characters:

El Pulpo and The Grasshopper, continuing their fiery friendship.
El Pulpo and The Grasshopper, continuing their fiery friendship.

Our heroes were then drawn by the fiery clarion call of the Serpent Mother:

Serpent Mother roars!
Serpent Mother roars!

The audience was transfixed:

The audience is transfixed by Serpent Mother.
The audience is transfixed by Serpent Mother.

Looking more closely, you can see the care put into the installation, all the moving parts and accumulators, and the labeling of each part:

It's very important to label your vertebrae.
It’s very important to label your vertebrae.

Elated, our heroes took the bridge back to the installation, and then home for a well-deserved rest:

And then the Golden Gate bridge wandered by.
And then the Golden Gate bridge wandered by.

Next time: A new day dawns!

Hat tip: http://www.elearnhub.org/how-to-make-an-animated-gif-in-gimp/ for how to make the animated .gifs.

[1]Or firey fiends. It’s difficult to tell, sometimes.

Burning Man in Pictures XLII: True Reflections

In our last installment, our heroes had gone a little playa-crazy from their adventures in the land of test pattern.

Now, it was time for them to rest and reflect on what they had experienced.

But first, the nose car:

Nose car.
Nose car.

Our intrepid heroes encounter a strange tent, titled ‘True Reflections Palace’. An arched entranceway beckons them in…:

What awaits inside? (It's difficult to tell because the sign is itself reflective.)
What awaits inside? (It’s difficult to tell because the sign is itself reflective.)

A welcoming sign:

This is the coolest tape we'd seen outside of Japan.
This is the coolest tape we’d seen outside of Japan.

It turns out that ‘True Reflections’ are what happens when you reflect a person’s image in such a way that it looks to them like they look to other people:

This was really spooky.
This was really spooky.

Of course, there were tinker toys, distracting to builders such as our heroes:

Tinkers toy!
Tinkers toy!

Up?:

Up?
Up?

THE WHOLE TENT IS TINKER TOYS:

Aha! The truth revealed!
Aha! The truth revealed!

Some research on this topic:

Research!
Research!

This is they type of coverage that you may have seen of this before, how the two halves of of the face are seen very differently, and how swapping them can have huge effects, most often done to celebrities so that people will click the link:

Not even Bruce Willis is immune.
Not even Bruce Willis is immune.

Some interesting commentary on the psychology of changing how someone sees themselves, possibly similar to people hearing themselves speak:

How people respond to their 'true reflection'.
How people respond to their ‘true reflection’.

They can probably tell you more, more succinctly and correctly than I can, so I leave you with a blatant (but happy) plug[1]:

A blatant (but happy) plug.
A blatant (but happy) plug.

Next time, our heroes encounter a (friendly) match between El Pulpo Mechanico and his grasshopper friend, and visit the Serpent Mother. Stay tuned!

[1]They are really cool, though. I feel like I look totally different in the ‘true mirror’, like twice as attractive. I wonder if this would help people understand privilege better…