← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
Practice/Google/Leetcode 2475. Number of Unequal Triplets in Array
CodingMust
Given an array of integers, count how many triplets of indices (i, j, k) exist where i < j < k and the values at these three positions are all different from each other.
In other words, for indices i, j, k where i < j < k, you need nums[i] ≠ nums[j], nums[j] ≠ nums[k], and nums[i] ≠ nums[k].
Example 1:
` Input: nums = [4, 4, 2, 4, 3] Output: 3 Explanation: The valid triplets are:
Example 2:
Input: nums = [1, 1, 1, 1, 1] Output: 0 Explanation: All elements are identical, so no triplet can have three different values.
Example 3:
Input: nums = [1, 2, 3] Output: 1 Explanation: Only one triplet (0, 1, 2) with values [1, 2, 3], all distinct.