In today’s world competition is everywhere. Any average software company is looking for candidates who are competitive. The simplest way for companies to evaluate competitiveness in candidates is by asking them a couple of algorithm interview questions.

A typical interview consists of two algorithm interview questions within 45 to 60 minutes of the timeframe. Throughout this time interviewer evaluates the candidate’s thought process and his ability to convert the thoughts to code or algorithm.

On this page, we are providing 20 easy to medium algorithms with a detailed explanation of the algorithm along with code (mostly written in C/C++ programming language).

Longest palindromic substring length of a given string (recursion and dynamic programming approach)

Count of all subsets with given sum in an unsorted integer array

Topological sort of an acyclic directed graph

Best complexity edit distance algorithm with an example

K-th largest or smallest element in an unsorted array of integers

Find the maximum subarray sum in an unsorted integer array

Find the median of an unsorted stream of integers at any given time

Reverse alternate group of K nodes in a singly linked list

Find root to leaf path whose sum is maximum in a binary tree

Print binary tree nodes in vertical order (vertical order traversal)

Find verticals sum of binary tree

Find the diameter of a given binary tree

Convert binary tree to its sum tree in-place

Check if given binary tree is complete

Find height of given binary tree

Find given two binary trees are identical

Find the median of two sorted arrays

Find if there exists a pair with a given sum in a sorted array.

To get more understanding of these algorithms, focus more on understanding the algorithms and testing with different edge cases (or requirements) and then focus on writing clean coding.

While writing the code re-check your code for any functional or programming errors.

Please let us know in comments if you have any algorithms that you want us to explain. All the very best for your interview prepation.