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 »