Every time you bump into a coding exercise with an obvious brute force solution, the first question you should ask is, “Can I use a hash map to optimise the solution?”. If so, that solution typically results in linear time complexity. If the answer is no, the second question should be, “Can I use sorting to optimise the solution?”. In this case, the limiting factor tends to be the sorting algorithm; the best algorithms such as Quick Sort or Merge Sort result in a O(NlogN) time complexity.
Continue reading
For most binary tree problems, recursive solutions are the most elegant and compact. LeetCode exercise Trim a Binary Search Tree is not an exception.
Continue reading
Traditional high-level programming languages such as Java, C#, and C++ were designed to support imperative/procedural programming. Modern programming languages such as Kotlin make it easier to code more functional and readable solutions. In this post, I start with an imperative, non-Kotlin-esque solution for the FizzBuzz code exercise; I then refine that solution in a series of steps, explaining the following Kotlin features along the way:
Continue reading
I often get asked: how do I practice for interview code exercises, and do something useful at the same time? Here is an idea.
Continue reading
Code katas are small coding exercises to sharpen your programming skills. In this post, I’ll show you my favourite code kata. The core idea is to resolve a relatively simple programming problem, following an exaggerated version of coding best practices.
Continue reading
Berlin Clock is a classic code exercise. The main challenge is to understand how time is represented, that may be confusing at first. Once you get your head around that, the algorithm itself is straightforward, so you should be able to code it fairly quickly.
Continue reading
This is the second part of a series of posts reviewing code exercise website to practice for a coding interview. I have started the series looking at Project Euler, this post will focus on Coding Bat.
Continue reading
I have started a new YouTube channel here. I will regularly upload videos about software engineering topics and programming exercises in particular. The first video walks you through the solution of the most famous code exercise - the FizzBuzz - in just over two minutes.
Continue reading
I have found a few good blog posts with reviews of code exercise websites. However, most of these posts are targeted at either competitive programmers or complete beginners. I am starting a series of posts reviewing the most popular programming exercise sites from the perspective of a programming job candidate.
Continue reading