Queries to find the length of the longest prefix from given array having all elements divisible by K
Given an array arr[] consisting of N elements and an arrayQ[], the task for each query is to find the length of the longest prefix such that all the elements of this prefix are divisible by K. Examples: Input: arr[] = {12, 6, 15, 3, 10}, Q[] = {4, 3, 2}Output: 1 4 2Explanation: Q[0] = 4: arr[0] (= 1