Count Triplets Within a Value Range

Given an integer array nums and an integer d, count the number of valid triplets.

A triplet consists of three distinct indices i < j < k. It is valid if:

max(nums[i], nums[j], nums...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: