<p>You are given a <strong>0-indexed</strong> array of positive integers <code>nums</code>. Find the number of triplets <code>(i, j, k)</code> that meet the following conditions:</p>

<ul>
	<li><code>0 &lt;= i &lt; j &lt; k &lt; nums.length</code></li>
	<li><code>nums[i]</code>, <code>nums[j]</code>, and <code>nums[k]</code> are <strong>pairwise distinct</strong>.
	<ul>
		<li>In other words, <code>nums[i] != nums[j]</code>, <code>nums[i] != nums[k]</code>, and <code>nums[j] != nums[k]</code>.</li>
	</ul>
	</li>
</ul>

<p>Return <em>the number of triplets that meet the conditions.</em></p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> nums = [4,4,2,4,3]
<strong>Output:</strong> 3
<strong>Explanation:</strong> The following triplets meet the conditions:
- (0, 2, 4) because 4 != 2 != 3
- (1, 2, 4) because 4 != 2 != 3
- (2, 3, 4) because 2 != 4 != 3
Since there are 3 triplets, we return 3.
Note that (2, 0, 4) is not a valid triplet because 2 &gt; 0.
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> nums = [1,1,1,1,1]
<strong>Output:</strong> 0
<strong>Explanation:</strong> No triplets meet the conditions so we return 0.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>3 &lt;= nums.length &lt;= 100</code></li>
	<li><code>1 &lt;= nums[i] &lt;= 1000</code></li>
</ul>

class Solution:
    def unequalTriplets(self, nums: List[int]) -> int:

        counter_nums=Counter(nums)
        counter_nums_keys=list(counter_nums.keys())
        len_counter_nums_keys=len(counter_nums_keys)
        triplets=0
        ii=0
        while ii<len_counter_nums_keys-2:
            jj=ii+1
            while jj<len_counter_nums_keys-1:
                kk=jj+1
                while kk<len_counter_nums_keys:
                    triplets=triplets+counter_nums[counter_nums_keys[ii]]*counter_nums[counter_nums_keys[jj]]*counter_nums[counter_nums_keys[kk]]
                    kk=kk+1
                jj=jj+1
            ii=ii+1

        return triplets

        #--------------brute force solution-------------------
        # nums.sort()
        # len_nums=len(nums)
        # len_nums=len(nums)
        # triplets=0
        # ii=0
        # while ii<len_nums-2:
        #     jj=ii+1
        #     while jj<len_nums-1:
        #         kk=jj+1
        #         while kk<len_nums:
        #             if nums[ii]!=nums[jj] and nums[jj]!=nums[kk] and nums[ii]!=nums[kk]:
        #                 triplets=triplets+1
        #             kk=kk+1
        #         jj=jj+1
        #     ii=ii+1

        # return triplets
        #-------------------------------this is for the number of singular triplets.----------------------
        # counter_nums=Counter(nums)
        # counter_nums_keys=counter_nums.keys()
        # triplets=0
        # while 1:
        #     distinct_numbers=0
        #     for counter_nums_key in counter_nums_keys:
        #         if not counter_nums[counter_nums_key]==0:
        #             counter_nums[counter_nums_key]=counter_nums[counter_nums_key]-1
        #             distinct_numbers=distinct_numbers+1
        #             if distinct_numbers==3:
        #                 break

        #     if not distinct_numbers==3:
        #         break
        #     else:
        #         triplets=triplets+1

        # return triplets

473