##
Convert array into Zig-Zag fashion
August 22, 2015

Given an array of distinct elements, rearrange the elements of array in zig-zag fashion in O(n) time. The converted array should be in form a… Read More »

August 22, 2015

Given an array of distinct elements, rearrange the elements of array in zig-zag fashion in O(n) time. The converted array should be in form a… Read More »

Let us elaborate the problem a little more. Basically, we are given an array of integers and we need to arrange this array in an… Read More »

August 16, 2015

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap… Read More »

There are n-pairs and therefore 2n people. everyone has one unique number ranging from 1 to 2n. All these 2n persons are arranged in random… Read More »

August 9, 2015

Given an array arr[] and a position in array, k. Write a function name reverse (a[], k) such that it reverses subarray arr[0..k-1]. Extra space… Read More »

July 30, 2015

Given an array with all distinct elements, find the largest three elements. Expected time complexity is O(n) and extra space is O(1).

July 1, 2015

Given two sorted arrays A and B, generate all possible arrays such that first element is taken from A then from B then from A… Read More »

June 23, 2015

Given an unsorted array of n integers which can contain integers from 1 to n. Some elements can be repeated multiple times and some other… Read More »

May 4, 2015

Given an array of integers, update every element with multiplication of previous and next elements with following exceptions.

May 1, 2015

Given two unsorted arrays that represent two sets (elements in every array are distinct), find union and intersection of two arrays.

April 22, 2015

Given an array of integers, write a function that returns true if there is a triplet (a, b, c) that satisfies a2 + b2 =… Read More »

April 8, 2015

Given an array of integers print the missing elements that lie in range 0-99. If there are more than one missing, collate them, otherwise just… Read More »

March 30, 2015

Given an array and a number ‘x’, write a function to delete ‘x’ from the given array. Input: arr[] = {3, 1, 2, 5, 90},… Read More »

February 25, 2015

Given an array of size n where all elements are in range from 0 to n-1, change contents of arr[] so that arr[i] = j… Read More »

December 28, 2014

Given a binary string, count number of substrings that start and end with 1. For example, if the input string is “00100101”, then there are… Read More »