# Category Archives: Arrays

## Arrange given numbers to form the biggest number | Set 2July 25, 2017

Given an array of non-negative numbers(of Integer Range), they are needed to be arranged in some order such that it gives the max number. For… Read More »

## Sorting Array Elements By Frequency | Set 3 (Using STL)July 24, 2017

Given an array of integers, sort the array according to frequency of elements. If frequencies of two elements are same, print them in increasing order.… Read More »

## Distinct adjacent elements in an arrayJuly 16, 2017

Given an array whether it is possible to obtain an array having distinct neighboring elements by swapping two neighboring array elements . Examples: Input :… Read More »

## Check if an array contains all elements of a given range

An array containing positive elements is given. ‘A’ and ‘B’ are two numbers defining a range. Write a function to check if the array contains… Read More »

## Check if array elements are consecutive in O(n) time and O(1) space (Handles Both Positive and negative numbers)July 15, 2017

Given an unsorted array of distinct numbers, write a function that returns true if array consists of consecutive numbers. Examples: Input : arr[] = {5,… Read More »

## Find an element in Bitonic array

Given a bitonic sequence of n distinct elements, write a program to find a given element x in the bitonic sequence in O(log n) time.… Read More »

## Serialize and Deserialize array of string

We have given an array of string and we have to serialize the array of string and deserialize the serialized string. Examples: Input : “geeks”,… Read More »

## Find the index of first 1 in a sorted array of 0’s and 1’sJuly 13, 2017

Given a sorted array consisting 0’s and 1’s. The problem is to find the index of first ‘1’ in the sorted array. It could be… Read More »

## Shuffle 2n integers in format {a1, b1, a2, b2, a3, b3, ……, an, bn} without using extra spaceJuly 12, 2017

Given an array of 2n elements in the following format { a1, a2, a3, a4, ….., an, b1, b2, b3, b4, …., bn }. The… Read More »

## Queries for counts of array elements with values in given range

Given an unsorted array of size n, find no of elements between two elements i and j (both inclusive). Examples: Input : arr = [1… Read More »

## Why is it faster to process sorted array than an unsorted array ?July 11, 2017

Here is a C++ code that illustrates that sorting the data miraculously makes the code faster than the unsorted version. Let’s try out a sample… Read More »

## Minimum Number of Platforms Required for a Railway/Bus Station | Set 2 (Map based approach)July 8, 2017

Given arrival and departure times of all trains that reach a railway station, find the minimum number of platforms required for the railway station so… Read More »

## Replace each node in binary tree with the sum of its inorder predecessor and successorJuly 7, 2017

Given a binary tree containing n nodes. The problem is to replace each node in the binary tree with the sum of its inorder predecessor… Read More »

## All unique triplets that sum up to a given valueJuly 6, 2017

Given an array and a sum value, find all possible unique triplets in that array whose sum is equal to the given sum value. If… Read More »

## Find four elements that sum to a given value | Set 3 (Hashmap)July 5, 2017

Given an array of integers, Check if there exist four elements at different indexes in the array whose sum is equal to a given value… Read More »