# Category Archives: Algorithms

## Count possible ways to construct buildings

Given an input number of sections and each section has 2 plots on either sides of the road. Find all possible ways to construct buildings… Read More »

## Flipkart Interview Experience | Set 21

I was interviewed at Flipkart. Following was my interview experience. Initially there was one telephonic screening round. then I was called at their bangalore office.… Read More »

## Maximum profit by buying and selling a share at most twice

In a daily share trading, a buyer buys shares in the morning and sells it on the same day. If the trader is allowed to… Read More »

## Check if any two intervals overlap among a given set of intervals

An interval is represented as a combination of start time and end time. Given a set of intervals, check if any two intervals overlap. Examples:… Read More »

## Puzzle 19 | (Poison and Rat)

There are 1000 wine bottles. One of the bottles contains poisoned wine. A rat dies after one hour of drinking the poisoned wine. How many… Read More »

## C Program for Iterative Merge Sort

Following is a typical recursive implementation of Merge Sort that uses last element as pivot. filter_none edit close play_arrow link brightness_4 code /* Recursive C… Read More »

## Java Program for Iterative Merge Sort

Following is a typical recursive implementation of Merge Sort that uses last element as pivot. Java filter_none edit close play_arrow link brightness_4 code // Recursive… Read More »

## Python Program for Iterative Merge Sort

Following is a typical recursive implementation of Merge Sort that uses last element as pivot. Python filter_none edit close play_arrow link brightness_4 code # Recursive… Read More »

## Iterative Merge Sort

Following is a typical recursive implementation of Merge Sort C/C++ filter_none edit close play_arrow link brightness_4 code /* Recursive C program for merge sort */… Read More »

## Given a sorted and rotated array, find if there is a pair with a given sum

Given an array that is sorted and then rotated around an unknown point. Find if the array has a pair with a given sum ‘x’.… Read More »

## Build Lowest Number by Removing n digits from a given number

Given a string ‘str’ of digits and an integer ‘n’, build the lowest possible number by removing ‘n’ digits from the string and not changing… Read More »

## Delete an element from array (Using two traversals and one traversal)

Given an array and a number ‘x’, write a function to delete ‘x’ from the given array. We assume that array maintains two things with… Read More »

## Subtract two numbers without using arithmetic operators

Write a function subtract(x, y) that returns x-y where x and y are integers. The function should not use any of the arithmetic operators (+,… Read More »

## Set Cover Problem | Set 1 (Greedy Approximate Algorithm)

Given a universe U of n elements, a collection of subsets of U say S = {S1, S2…,Sm} where every subset Si has an associated… Read More »

## K Centers Problem | Set 1 (Greedy Approximate Algorithm)

Given n cities and distances between every pair of cities, select k cities to place warehouses (or ATMs or Cloud Server) such that the maximum… Read More »