Company: OYO

Difficulty: medium

Problem Statement

Fruit Selection Operations You are given prices of `N` fruits, numbered from 1 to `N`. Process `Q` queries. For a query `(type, X, Y)`, select positions `X, X + Y, X + 2Y, ...` that do not exceed `N`. - If `type` is `1`, print the sum of the selected prices modulo `1000000007`. - If `type` is `2`, print the product of the selected prices modulo `1000000007`. Input Format The first line contains `N`. The second line contains `N` integer prices. The third line contains `Q`. Each of the next `Q` lines contains `type X Y`. Output Format For each query, print its answer on a new line. Constraints `1 <= N, Q <= 2000`, `1 <= price <= 10^9`, `1 <= X, Y <= N`. Notes Positions are 1-indexed. Position `X` is always selected. The modulo is applied to every reported answer.

More OYO OA questionsInterview experiences