Given heights of n towers and a value k. We need to either increase or decrease height of every tower by k (only once) where… Read More

# Category Archives: Arrays

Given a square matrix, turn it by 90 degrees in anti-clockwise direction without using any extra space. Examples : Input: Matrix: 1 2 3 4… Read More

Given an array of positive integers. We need to make the given array a ‘Palindrome’. The only allowed operation is”merging” (of two adjacent elements). Merging… Read More

I was recently interviewed by Amazon, Bangalore for SDE position. It was an off campus drive in Delhi for TRMS team. Written Test : Q1)… Read More

Branch and bound is an algorithm design paradigm which is generally used for solving combinatorial optimization problems. These problems typically exponential in terms of time… Read More

Consider an array with n elements and value of all the elements is zero. We can perform following operations on the array. Incremental operations:Choose 1… Read More

Given an array of integers, and a number ‘sum’, find the number of pairs of integers in the array whose sum is equal to ‘sum’.… Read More

Given two arrays which are duplicates of each other except one element, that is one element from one of the array is missing, we need… Read More

Given an unsorted array, find the minimum difference between any pair in given array. Examples : Input : {1, 5, 3, 19, 18, 25}; Output… Read More

Recently, VMWare has visited our campus for hiring interns and they have put a CGPA cut off of 7/10. There were 2 rounds in total.… Read More

Given a sorted array of positive integers, rearrange the array alternately i.e first element should be maximum value, second minimum value, third second max, fourth… Read More

Given an array of integers, count number of subarrays (of size more than one) that are strictly increasing. Expected Time Complexity : O(n) Expected Extra… Read More

Subarray/Substring A subbarray is a contiguous part of array. An array that is inside another array. For example, consider the array [1, 2, 3, 4],… Read More

Given a Binary Number as a string, print its 1’s and 2’s complements. 1’s complement of a binary number is another binary number obtained by… Read More

The longest Zig-Zag subsequence problem is to find length of the longest subsequence of given sequence such that all elements of this are alternating. If… Read More