Online Assessment Question Need Help!!
Anonymous User
637

Anyone Can Solve the Questions asked in a coding round.
Given an array A of N integers and an integer X the task is to count all triplets(i, j, k) where 1<= i <= j <= k<= N which satisfies the following condition.
1 X <= j - i and X<= k - j
2 a[i] a[j] a[k] are odd

input : N = 4
X = 1
A = [1,2,3,3]
Output: 1
there is only one triplet (i = 1, j = 3, k = 4) which satifies all condition

Const: 1 <=X <= N <= 10^5
1 <= A[i] <= 10^5

Comments (6)