INNOVITI PAYMENTS Off-Campus OA (2021) | Problem Number of Arithmetic Triplets

Question · Posted Jun 2026

Problem Statement You are given a strictly increasing integer array nums and an integer diff. Return the number of unique arithmetic triplets (i, j, k) such that: i < j < k nums[j] - nums[i] = diff nums[k] - nums[j] = diff Example Input nums = [0,1,4,6,7,10] diff = 3 Output 2 Explanation Valid triplets: (1,4,7) (4,7,10) Total = 2 Constraints 3 <= nums.length <= 200 0 <= diff <= 50 nums is strictly increasing

The full answer & interview discussion are available to premium members.

Log in Create a free account