Category Archives: Arrays

Questions regarding Arrays

Largest divisible subset in array

Given an array the task is to largest divisible subset in array. A subset is called divisible if for every pair (x, y) in subset, either x divides y or y divides x. Examples: Input : arr[] = {1, 16, 7, 8, 4} Output : 16 8 4 1 In the output subset, for every… Read More »

Maximum value in an array after m range increment operations

Consider an array of size n with all initial values as 0, we need to perform following m range increment operations. increment(a, b, k) : Increment values from ‘a’ to ‘b’ by ‘k’. After m operations, we need to calculate the maximum of the values in the array. Examples: Input : n = 5 m… Read More »

Check if two arrays are equal or not

Given two given arrays of equal length, the task is to find if given arrays are equal or not. Two arrays are said to be equal if both of them contain same set of elements, arrangements (or permutation) of elements may be different though. Note : If there are repetitions, then counts of repeated elements… Read More »