How to prepare for and ace your assessment on Coderbyte

An expert guide to getting HIRED

Harriet Obwogo
Tech x Talent
3 min readJul 1, 2020

--

I got a chance to interview for the Microsoft LEAP apprenticeship program and I’m thrilled to say that it was a success. The past two months have been involving and the growth is real and immense. one thing I learned is that as a software engineer problem-solving skills are a major requirement. If you don’t have that then developing products that have high productivity isn’t really going to happen.

As a software engineer, your work is to solve problems, and sometimes solving problems doesn’t necessarily mean writing code all the time, sometimes it might involve getting rid of code. “To create something original you must first identify the problem, break it down, and then develop different ways to approach and learn from it. Problem-solving is an art” and as a developer, there’s no shortcut around that.

Below are the algorithmic challenges from Coderbyte and my approaches to solving them. Keep in mind that Coderbyte has since changed the challenges and introduced cheat-proofing so that every solution must be 100% unique.

I’ll be using C# and for a start, I’ll do some easy challenges. the trick is to just wrap your head around the problem, understand the logic, write it down on paper and test it before writing the actual code

1.Consecutive

Have the function Consecutive(arr) take the array of integers stored in arr and return the minimum number of integers needed to make the contents of arr consecutive from the lowest number to the highest number. For example: If arr contains [4, 8, 6] then the output should be 2 because two numbers need to be added to the array (5 and 7) to make it a consecutive array of numbers from 4 to 8. Negative numbers may be entered as parameters and no array will have less than 2 elements.

  1. check for the edge cases i.e if the array is within the limits provided
  2. Loop through the array, find the maximum and minimum elements in the array. This will give you a range within which your numbers lie.
  3. Find and return the difference between the Min and Max and the array Length.

2.LargestFour

Have the function LargestFour(arr) take the array of integers stored in arr, and find the four largest elements and return their sum. For example: if arr is [4, 5, -2, 3, 1, 2, 6, 6] then the four largest elements in this array are 6, 6, 4, and 5 and the total sum of these numbers is 21, so your program should return 21. If there are less than four numbers in the array your program should return the sum of all the numbers in the array.

One way to go about this is to sort the array in ascending order and extract the subarray starting from the fourth index, find the sum and return the sum.

1. First, check for edge cases, return 0 or -1 if the array is empty. otherwise, if it has less than four elements, find their sum and return it.

2. sort the array

3. loop through the array

4. take the subarray of the last four elements and store them in an array

5.find their sum and return.

Time Complexity O(n), space complexity O(n)

I’ll leave it at that for today. Comment down below if you want more of this and how better we can do it.

--

--

Harriet Obwogo
Tech x Talent

Back-end software developer. A Tech Enthusiast, mentor and friend to all.