You are given an integer array A of length N and an integer target.
Your task is to count the number of unique triplets (i, j, k) satisfying both of the following conditions:
Distinct Indices: i, j, k are distinct indices such that 0 ≤ i, j, k < N.
Adjacency Constraint: At least two of the chosen elements are adjacent in the array. (That is, either |i - j| = 1, or |j - k| = 1, or |i - k| = 1.)
Product Constraint: The product of the chosen elements equals target. Formally: A[i] × A[j] × A[k] = target
Return the number of unique triplets (i, j, k) that satisfy all the above conditions.
Expert in Data Structures & Algorithms. Building tools to help developers crack FAANG interviews.