StriveNine Core Algorithms Course

S9 prides itself on its forward thinking and innovative interviewing and hiring practices. We don’t say no to candidates, we say not yet. In order to be a successful developer at S9, you need to have a certain set of knowledge. It doesn’t really matter when you acquire this knowledge, but you must know it well before being considered to join S9. While knowledge is just one part of the puzzle to be a successful S9 developer, it is an important piece.

This course describes the core set of knowledge that is necessary to have success at S9. Your experience level doesn’t matter, you must know all of this well! If you want to get through the interview process at S9 with little difficulty, study this course first!

There are two parts to the StriveNine interview process for Javascript Developers.

  • Core Competencies – Do you understand data structures, do you understand the time complexity of different data structures, and do you understand how javascript actually works?

  • Algorithm Concepts – Can you write code?

This course describes what we are looking for in the Algorithm Concepts part of our interview process. For more information on our Core Competencies, please see the StriveNine Core Javascript Course.

When it comes to writing algorithms, there are two main threads we are looking for

  • Time Complexity – Do you understand key time complexity concepts?

  • Problem Solving – Can you explain your path to a solution? Can you explain the concepts you are using to solve the problem. Can understand suggestions and use them to solve the problem?

Time Complexity

First and foremost, if you do not understand basic time complexity of algorithms, you are missing one of the key components to becoming a great developer. PERIOD. So what should you know?

  1. Know the time complexity for common data structures. Without knowing this you will NOT be able to optimize many of the algorithm problems you are trying to solve.

  2. Understand the following time complexities and know examples of each.

    1. Constant Time O(1) – A single operation, or an operation based on a constant value. e.g. Map reads and writes.

    2. Linear Time O(n) – You touch every item exactly once. e.g. A single for loop over every element in an array. Something to remember, if you have an unbalanced tree then you will need to touch every single item in the tree at least once in the worst case to find an a specific node in the tree. This would also be linear.

    3. Quadratic Time O(n^2) – You touch every item exactly once, for every single item. e.g. Nested for loops or Bubble Sort

    4. Logarithmic Time O(log n) – Consider a balanced tree with any number of children at a given node (log base is ignored in Big O). If I am searching for an item in the tree, I do not need to touch every element. In the worst case, I need to touch one element at every level of the tree. The height of the tree is equal to the log of the number of items in the tree.

    5. Exponential Time O(2^n) – The concept here is similar to logarithmic time. Consider the Fibonacci recursive algorithm. You can visualize this as a tree where each node of the tree is another recursive call, that is making two more recursive calls. Here, ‘n’ represents the depth of the recursion tree.

  3. Know the difference between two nested for loops and two for loops side by side. If you have 100 items in an array and your process with a nested for loop, you would have a total of 100 * 100 = 10,000 iterations. But if you find a way to process using two side by side loops instead, you would only have 100 + 100 = 200 iterations.

    1. So many programming problems test this concept. e.g. Get the intersection of two arrays. Instead of using nested for loops, you can convert one of the arrays into a map (which would be O(n)). You can then utilize the O(1) lookup times from the map while looping through the second array (O(n)), searching for matches. This would give you O(2n), but we would just drop the constant and get O(n).

Problem Solving

Things that StriveNine will never do:

  • Ask you to write an algorithm on a white board. Turns out that isn’t something you will need to do if you get hired, so why would we test that?

  • Ask random algorithms that don’t test concepts that are directly related to the work we do at StriveNine.

  • Fail a candidate because they don’t know the answer to a single algorithm. Whats more important, is seeing if you can learn the concept and apply it to a different algorithm.

  • Expect you to have any algorithms memorized. We often see this in places with sorting algorithms. Memorizing algorithms is a waste of your time. But if someone explains the concepts of an algorithm (such a sorting algorithm), you should be able to take those concepts and turn them into an algorithm.

  • Ask riddles. Seriously though, if someone asks you a riddle in an interview, PLEASE WALK OUT! Riddles are in no way an indicator to the potential of a developer.

So how can you prepare yourself for problem solving?

  1. Practice, practice, practice, and practice! Checkout LeetCode, Pramp, etc. These are great resources for practicing algorithms with a similar environment to an interview.

  2. Don’t let yourself get hung up on some little thing. Keep your mind focused on the bigger problem.

  3. Write tests. Yes, even in your interview, write some basic tests to help you understand how close you are to a solution.

  4. If you do get stuck, start console logging. You can also physically write down what values would be a different parts of your code with specific inputs. If you stay calm and start doing this, it will usually help you get unstuck.

  5. Before you write code, explain what your solution will be, and explain the expected time complexity.

  6. Ask questions and listen to the hints the interviewer is providing.

A Few Algorithms With Important Concepts

  • Merge Sort – Semi-difficult recursion problem.

  • Depth First Search / Breadth First Search – Tree algorithms

  • Intersection of two arrays – First convert one array into a map so you can achieve O(n).

  • Write a function called ‘sum’ so that, ​sum(a, b) === sum(a)(b) – Do you understand the power of currying and higher order functions?