LeetCode solutions

2566. Number of Unequal Triplets in Array

My accepted Python solution to LeetCode problem 2566, Number of Unequal Triplets in Array, running in 238ms.

  • Difficulty: Easy
  • Python
  • Runtime 238ms
  • Memory 17.2MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 238ms, memory 17.2MB, accepted 2026-01-01.

python
class Solution:
    def unequalTriplets(self, nums: List[int]) -> int:
        count = 0
        n = len(nums)
        for i in range(n):
            for j in range(i+1, n):
                for k in range(j+1, n):
                    if nums[i] != nums[j] and nums[j] != nums[k] and nums[i] != nums[k]:
                        count += 1
        return count

Source