Yi-Hsiang Kao
4 min readOct 7, 2018

--

A Sample Problem — — Train to be an Interview Problem Solver (1)

Recently I’ve started interviewing for different companies, and for a software engineer role, there would definitely be rounds for technical interviews (well, also known as whiteboard coding interview, notoriously). In this kind of interview, you’ll have to write some codes to solve a given problem, analyzing different solutions and come up with the best methods based on the given conditions. Usually, a well-trained interviewer (engineer) will evaluate a candidate by the following observations:

1. Problem analysis
2. Algorithm & data structure
3. Coding ability
4. Culture fitting & Cleverness

One could mostly learn the second and the third from school courses, however, it is from practicing and experiences that you can know how to tackle a problem and analyze from different aspects.

Here, I would like to show a sample problem that could be tackled from different approaches, while each could be applied in different scenarios.

So, let’s get down to the problem.

You have two inputs: N, M
Write a function that could print out M ordered numbers sampled from 0 ~ N-1
The probability for choosing each combination should be the same.
For example -> N = 3, M = 2

The function should print out [0,1] or [0,2] or [1,2]
The probability for printing out [0,1], [0,2]

--

--