Set both elements of a binary array to 0 in single line

Given an binary array of size two having alteast one element as zero, write a single line function to set both its elements to zero. Use of ternary operator and direct assignment of elements are not allowed.

K-Partition Problem | Printing all Partitions

In k-partition problem, we need to partition an array of positive integers into k disjoint subsets that all have equal sum and they completely covers the set.

3-Partition Problem

3-partition problem: Given a set S of positive integers, determine if it can be partitioned into three disjoint subsets that all have same sum and they cover S.

Iterative Merge Sort Algorithm (Bottom-up Merge Sort)

In this post, we will see how to sort an array of integers using iterative merge sort algorithm.

Rearrange array such that A[A[i]] is set to i for every element A[i]

Given an unsorted array of integers whose each element lies in range 0 to n-1 where n is the size of the array, rearrange array such that A[A[i]] is set to i for every element A[i] in the array. Do this in linear time and without using any extra constant space.

Find two odd occurring element in an array without using any extra space

Given an array of integers, duplicates appear in it even number of times except two elements which appears odd number of times. Find both odd appearing element without using any extra memory.

Convert Min Heap to Max Heap in O(n) time

Given an array representing a Min Heap, convert Min Heap into a Max Heap. The conversion should be done inplace and in linear time.

Reverse every consecutive m elements of the given subarray

Given an array, reverse every group of consecutive m elements in given subarray of it.

Find all distinct combinations of given length – Part 2

Given an array of integers, find all distinct combinations of given length.

Maximum Product Subset Problem

Given an array of integers, find a subset in it that has maximum product of its elements.

Find Pairs with Difference k in the Array | Constant Space Solution

Given an unsorted array of integers, print all pairs with given difference k in it without using any extra space.

Find pairs with given difference k in the array

Given an unsorted array of integers, print all pairs with given difference k in it.