# Category Archives: Arrays

## Clustering/Partitioning an array such that sum of square differences is minimum

Given an array of n numbers and a number k. We need to divide the array into k partitions (clusters) of same or different length.… Read More »

## Find whether it is possible to make array elements same using one external number

Given an Array, three operations can be performed using any external number x. Add x to an element once Subtract x from an element once… Read More »

## Remove minimum elements from array such that no three consecutive element are either increasing or decreasing

Given an array of n distinct positive integers. The task is to find the minimum number of elements to be removed such that no three… Read More »

## Smallest Difference pair of values between two unsorted Arrays

Given two arrays of integers, compute the pair of values (one value in each array) with the smallest (non-negative) difference. Return the difference. Examples: Input… Read More »

## Program to print an array in Pendulum Arrangement

Write a program to input a list of integers in an array and arrange them in a way similar to the to-and-fro movement of a… Read More »

## Largest sum contiguous increasing subarray

Given an array of n positive distinct integers. The problem is to find the largest sum of contiguous increasing subarray in O(n) time complexity. Examples:… Read More »

## Prefix Sum Array – Implementation and Applications in Competitive Programming

Introduction and Implementation : Given an array arr[] of size n, its prefix sum array is another array prefixSum[] of same size such that the… Read More »

## Find missing number in another array which is shuffled copy

Given an array ‘arr1’ of n positive integers. Contents of arr1[] are copied to another array ‘arr2’, but numbers are shuffled and one element is… Read More »

## Smallest Difference Triplet from Three arrays

Three arrays of same size are given. Find a triplet such that maximum – minimum in that triplet is minimum of all the triplets. A… Read More »

## Program for average of an array (Iterative and Recursive)

Given an array, the task is to find average of that array. Average is the sum of array elements divided by the number of elements.… Read More »

## Program to check if an array is sorted or not (Iterative and Recursive)

Given an array of size n, write a program to check if it is sorted in ascending order or not. Equal values are allowed in… Read More »

## Count of arrays in which all adjacent elements are such that one of them divide the another

Given two positive integer n and n. The task is to find the number of arrays of size n that can be formed such that… Read More »

## Subsequence with maximum odd sum

Given a set of integers, check whether there is a subsequence with odd sum and if yes, then finding the maximum odd sum. If no… Read More »

## Minimum toggles to partition a binary array so that it has first 0s then 1s

Given an array of n integers containing only 0 and 1. Find the minimum toggles (switch from 0 to 1 or vice-versa) required such the… Read More »

## Count the number of subarrays having a given XOR

Given an array of integers arr[] and a number m, count the number of subarrays having XOR of their elements as m. Examples: Input :… Read More »