Ctrl K

Three Different Values

Easy
You are given an array of positive integers values. Count the index triples i < j < k for which values[i], values[j] and values[k] are all pairwise different.
Example 1
values=[7, 3, 7, 5] → 2

Index triples (0, 1, 3), with values 7, 3, 5, and (1, 2, 3), with values 3, 7, 5, qualify. Triples with both 7s do not. The answer is 2.

Example 2
values=[2, 2, 9, 9] → 0

There are only two distinct values, so no three can be pairwise different. The answer is 0.

Example 3
values=[1, 2, 3, 4] → 4
Constraints
  • 3 ≤ len(values) ≤ 100
  • 1 ≤ values[i] ≤ 1000
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsThe Candidate With Most Votes EasyDoes Any Value Repeat EasyThe Lost Ticket EasyValues in Both Lists EasyShared Values With Repeats Easy
loading Python…
Input
values=[7, 3, 7, 5]
Expected
2

Run checks the first 3 tests in your browser. Submit checks all 75 tests on the server, hidden ones included.