Check duplicate parenthesis in an expression

A valid mathematical expression can also have duplicate parenthesis as shown below: ((a+b)) (((a+(b)))+(c+d)) Write code to find if an expression has duplicate parenthesis. You […]

Next greater element

Print Next Greater Element for every element in the array. The Next greater Element of element x is first greater element on its right side. […]

Introducing Graph Data Structure with Adjacency matrix implementation

Binary tree is a specialization of Graph data structure. Node in a Graph is called a Vertex and the connection between two vertices is called […]

Recursive implementation of Insertion Sort

We discussed Insertion sort in detail earlier. This post shows the recursive implementation of Insertion Sort.

Count frequency of a number in a sorted array

Given a sorted array of numbers and a number x, count the number of occurrences of x in the array. Input: int arr[] = {1, […]

Counting Sort

It is used when there are few unique elements in an array. Counting sort takes O(n+k) time in the worst case, where n is number […]

Generic pointers in C language

Generic programming, loosely means that the code we have written is type-independent. It is a larger topic, macros in C language also comes under generic programming. […]

Add sum of all previous elements in array (DPFCI_1.2)

This question is from exercise in my book Dynamic Programming for Coding Interviews (Question: 1.2, Page-5) Question: Given an array, arr of integers, write a […]

Find minimum of 3 numbers without using comparator operator

How will you find minimum of three integers without using any comparison operator ?

Merge two sorted arrays

Given two sorted arrays of size m and n respectively. Also given an empty third array of size (m+n). write code to merge the two […]