Member-only story

Interview question: Search missing number in an array that contains integers from 0 to 20

Crystal X
2 min readMay 23, 2023

--

When going on a Python developer interview, it is quite likely that you are going to be asked to create a few algorithms to solve common problems in the language.

In this blog post, I intend to solve the problem of searching for a missing number in an array that contains integers from 0 to 20.

The solution to this problem can be found in the following psuedocode:-

  1. Define the variable, num_lst, which is a list of integers from 0 to 20, with a few digits missing.
  2. Define the function, find_missing, which accepts a list as input.
  3. Within the function, create a for loop where the variable i will iterate through 0 to the length of the list, incrementing by one. During each iteration, if i is not in the list the function will print the missing number in the list.

The code in python for this algorithm can be seen below:-

I devised the above algorithm myself, but I did conduct a bit of research and did find another algorithm on a well known coding website. When I tested the algorithm, however, it didn’t work, and that is why I have not included it in this blog post.

--

--

Crystal X
Crystal X

Written by Crystal X

I have over five decades experience in the world of work, being in fast food, the military, business, non-profits, and the healthcare sector.

No responses yet