A sorted array is rotated at some unknown point, find the minimum element in it. Following solution assumes that all elements are distinct.
Given a function ‘int f(unsigned int x)’ which takes a non-negative integer ‘x’ as input and returns an integer as output.
Given an array of integers. Find a peak element in it. An array element is peak if it is NOT smaller than its neighbors. For… Read More »
Given two binary strings that represent value of two integers, find the product of two strings. For example, if the first bit string is “1100”… Read More »
Find the largest rectangular area possible in a given histogram where the largest rectangle can be made of a number of contiguous bars. For simplicity,… Read More »
You are given a one dimensional array that may contain both positive and negative integers, find the sum of contiguous subarray of numbers which has… Read More »
Like QuickSort, Merge Sort is a Divide and Conquer algorithm. It divides input array in two halves, calls itself for the two halves and then… Read More »
We are given an array of n points in the plane, and the problem is to find out the closest pair of points in the… Read More »
Like Greedy and Dynamic Programming, Divide and Conquer is an algorithmic paradigm. A typical Divide and Conquer algorithm solves a problem using following three steps.
This is an extension of median of two sorted arrays of equal size problem. Here we handle arrays of unequal size also.
Given an array of integers which is initially increasing and then decreasing, find the maximum value in the array.
Given an array of n distinct integers sorted in ascending order, write a function that returns a Fixed Point in the array, if there is… Read More »
Given a sorted array arr and a number x, write a function that counts the occurrences of x in arr. Expected time complexity is O(Logn)
Given an integer array of length N (an arbitrarily large number). How to count number of set bits in the array?
Method 1 (Using Nested Loops) We can calculate power by using repeated addition.