Skip to content

Category Archives: Divide and Conquer

Given an integer array of length N (an arbitrarily large number). How to count number of set bits in the array?The simple approach would be, create an… Read More
Method 1 (Using Nested Loops): We can calculate power by using repeated addition. For example to calculate 5^6.  1) First 5 times add 5, we get… Read More
Given an array of size N. The task is to find the maximum and the minimum element of the array using the minimum number of… Read More
Given an array arr of N elements,  A majority element in an array arr of size N is an element that appears more than N/2… Read More
Inversion Count for an array indicates – how far (or close) the array is from being sorted. If the array is already sorted, then the… Read More
  There are 2 sorted arrays A and B of size n each. Write an algorithm to find the median of the array obtained after… Read More
Given two integers x and n, write a function to compute xn. We may assume that x and n are small and overflow doesn’t happen.… Read More

Start Your Coding Journey Now!