This is a verified interview question from Ms-(microsoft). Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Count Triplets with Adjacency and Product Constraint" covers key patterns like Other.
"### Problem 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: 1. **Distinct Indices**: i, j, k are distinct indices such that 0 ≤ i, j, k < N. 2. **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.) 3. **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."
Join thousands of developers practicing for Ms-(microsoft).