Category Archives: Arrays

Questions regarding Arrays

Maximum occurred integer in n ranges

Given n ranges of the form L and R, the task is to find the maximum occurred integer in all the ranges. If more than one such integer exits, print the smallest one. 0 <= Li , Ri < 1000000. Examples: Input : L1 = 1 R1 = 15 L2 = 4 R2 = 8… Read More »

Check loop in array according to given constraints

Given an array arr[0..n-1] of positive and negative numbers we need to find if there is a cycle in array with given rules of movements. If a number at an i index is positive, then move arr[i]%n forward steps, i.e., next index to visit is (i + arr[i])%n. Conversely, if it’s negative, move backward arr[i]%n… Read More »

Subset sum queries using bitset

Given an array arr[] and a number of queries, where in each query we have to check whether a subset whose sum is equal to given number exists in the array or not. Examples: Input : arr[] = {1, 2, 3}; query[] = {5, 3, 8} Output : Yes, Yes, No There is a subset… Read More »