I enjoy doing code exercises in my spare time. Below are some of my solutions that I have written in C, C++ or C# for the exercises provided from three sources: Codility, HackerRank and Gayle Laakmann McDowell’s book “Cracking the Coding Interview“.


All solutions scored 100% unless explicitly indicated otherwise. On occasion I will upload poorer scoring solutions as part of my discussion, and describe how the solutions can be optimised.

You can click on the links to my solutions below. They are organised according to Codility lesson.


BinaryGap (Painless, C/C++)

(Bonus – Determining whether an integer is a power of two)


OddOccurencesInArray (Painless, C++)

(Bonus – swapping variables without using a temporary variable)

CyclicRotation (Painless, C)

Time Complexity

FrogJump (Painless, C/C++)

PermMissingElem (Painless, C++)

Counting ElementsĀ 

MissingInteger (Painless, C++)

MaxCounters (Respectable, C++)


MaxProductOfThree (Painless, C#)

Triangle (Painless, C#)

Stacks and queues

Brackets (Painless, C#)

Cracking the code interview

Anagrams (Sorting and searching)

Merge Sorted Arrays (Sorting and searching)

Magic Index (Recursion and Dynamic Programming)

Permutations (Recursion and Dynamic Programming)

Powerset (Recursion and Dynamic Programming)


Maximum Depth of Binary Tree

Invert Binary Tree

kth largest element in an array medium

Reverse String 2


Staircase (Easy)

Between Two Sets (Easy)

Data Structures and Algorithms Bootcamp (Udemy)

UniqueCharacters (Common interview questions)

IsPermutation (Common interview questions)

OneAway (Common interview questions)