There are many posts online dedicated to questions an applicant for a developer role can be asked. Most of those questions are basic, intro level, aiming at verifying that a candidate is above some basic level of knowledge (for example, checkout the 100+ Coding Interview Questions for Programmers post - those questions are either entry level, algorithmic or very simple solving questions). This is not how we interview and those are not the questions we ask.
In an interview, the questions we ask take about 15 min to answer, and there are no single correct answers. What we are looking for is to evaluate the candidate based on the discussion itself, their thought process, and their experience.
The first thing we are checking is if we can actually talk with the candidate? Can we understand each other? Have a good conversation about a technical problem? Pros / Cons of different options? Does the candidate understand my requirements? Can they find solutions? Find missing needs? Detect blind spots? Can they challenge?
Let’s dive into an example:
We have 10 image files on a disk, on my MacBook. I want to sharpen those images using an algorithm called USM - it is a CPU intensive algorithm, with running time that depends on the image size - running about 2-10ms per megabyte of image size.
Given an image sharpening library is available, how do we write the code to sharpen the images?
Any programming language can be used here. We are not even looking for code that actually compiles - we are looking for ideas and patterns, not exact syntax.
At this point, most users answer something like -
Well, that was a great PoC. We have an application to sharpen images.
However, since we are working for Wix, we have a bit more images that we need to sharpen. 1,200,000 images to be exact. We have all the files in a drive, with a text file containing all the file names.
How does the answer above change now that we have 1,200,000 images to process?
At this point, there are two directions candidates take - either scaling out, or continuing to work on a single host.
For the people who are suggesting to scale out, we will ask what approach they consider? Building their own scale-out infrastructure? Using Kubernetes, and if so then how? Using functions? Again how would those be used? We will spend a few minutes looking into proposed solutions and understanding how they intend to build such a system, then refocus on the single host option - as this is still a simple enough problem that does not require long dev cycles.
Lets dig into single host - assuming the MacBook in question has 16 Cores (it has a powerful CPU), how can we minimize the time for the image processing to complete?
The first answer that we commonly hear is to split the names array into X groups, and process each in turn. This means loading all file names into memory as an array, splitting that array into X arrays, each containing 1/X of the names, and processing the files in turn. The code for such a solution looks something like the following:
With this solution, we wait for the candidate to raise any of the following concerns - and if not, we will actively ask the following questions.
Is there a concern about the memory load of loading 1,200,000 file names? 1,200,000 file names take about 1GByte of memory, so most MacBooks today should be able to handle it.
What is the right value for X? How does it correlate to the number of CPU Cores? Many people will answer 16, as that’s the number of Cores, but that can leave the computer unresponsive. Maybe it is better to assume 15?
What will be the running time of such an application? Assuming each image is about ~10 MBytes, it can be sharpened within 100 ms. Add about 10-50 ms for reading each file and writing it back to the hard drive - the process will take about 4-5 hours of runtime to complete.
Given the process will take hours to run, is there a concern about bugs, crashes, restarts, etc? How do you handle those?
Is this the most efficient way to run this process? (answer - no).
So, how can we make this process run faster? What is the optimal algorithm?
At this point, normally the candidate starts thinking creatively. We are looking for two aspects in this part of the interview - their ability to be creative and their understanding of IO.
Some leading questions -
What if the groups are not balanced? What if group 2 ends up with all the large images, while group 1 with all the small images? What if group 1 completes the processing way before group 2?
How do we utilize the resources to the best possible extent?
The answer we are looking for is splitting the process per resource, using different queues - one for IO, another - for CPU. The candidate can use an Actor model, or a consumer / producer model, or just a simple queueing model.
One such solution is below -
The follow-up questions for this solution are -
How many concurrent operations do we allow for each queue? What values for X, Y and Z? A good answer is 15 for the processing queue (number of Cores - 1) and 1 for both IO queues.
Can we improve this solution in any way?
To summarise, when we interview people for technical positions, asking a question like that takes up a large part of the interview process. However, it is not the only screening means.
We are also asking each candidate to actually write code as part of the interview - on an actual computer, with all the online resources they are used to. This can be done in the office, at home, or while doing pair programming with one of our developers.
We are also diving into the things the candidate has done at their previous places of work, what they have built, what was their part in the decision making process (technical aspects of it), etc.
Last, we take the insights from all the interviews to help us better understand if we have a good fit for the candidate. A question we have raised in this post plays a large part in forming that understanding.
Photo by Olav Ahrens Røtne on Unsplash
This post was written by Yoav Abrahami
You can follow him on Twitter
For more engineering updates and insights:
Visit us on GitHub
Subscribe to our YouTube channel
@idan.net - all are good points, exactly what we are looking for in such a question.
You are hired! 😜
I thought that you'll take this conversation way further. I mean, at the end, you just asked a question that is a bit more complicated than find x in string y.
I thought that the questions you'd expect would be:
1. Does the images really need to be 10mb each? Can we scale them down before we sharpen them (and save significant amount of time)
2. Do we really need all 1.2 million images? And if we do - can we prioritize it?
3. Why not do it in realtime when in use? Is the heuristics not showing that only small portion of the images are actually in use?
This sort of interview question is decent, but ultimately any question that lacks real-world context (as almost all interview coding quizzes seem to) risks rejecting or alienating very experienced candidates who are not good at solving "text book" style problems. Personally I have never met a problem I couldn't crack on real-world projects because you can answer any question by bringing it back to the stakeholders (users, programmers, managers, investors). With a decontextualized "textbook style" question like you've presented here, my intuition would be subverted, and I would have trouble coming up with the right questions not knowing what purpose the software served for actual people. At best I could ask questions to clarify why this software is needed and…
I, too, signed up just to comment. I considered myself an old school dev and was asked similar, find the index of x in string y, type of questions in most of my job interviews. I think I turned out to be pretty valuable and fit in my company.
My point is, it's ok to ask whatever question you want, as long as you know what to get out from it.
I joined this site honestly just to post that if someone threw me a question like I would answer but honestly write that company off. This is way too much overkill, notice I said way too much overkill, for a developer interview. I mean come on, you are wanting and expecting the world and I would read your scenario as a candidate as "these people want to milk every last drop out of their employees and expect them to have it done yesterday". Times aren't tough right now for devs, people have options so just my 2 cents, don't give people the wrong impression of your company by doing this unless you really want to send that message to y…