Number of Unequal Triplets in Array
A easy-tier problem at 73% community acceptance, tagged with Array, Hash Table, Sorting. Reported in interviews at Paytm and 0 others.
You're looking at a problem that sounds like basic array work but catches people off guard because the naive solution looks right until you submit it. Number of Unequal Triplets asks you to count triplets where all three elements differ. Paytm has asked it. The 72.6% acceptance rate is misleading, it drops fast once you realize the gotcha in what 'unequal' actually means. Most candidates either overthink this into O(n^3) hell or miss a constraint that flips the solution. StealthCoder reads the problem, spots the pattern, and surfaces a working approach in seconds if you blank on the live assessment.
Companies that ask "Number of Unequal Triplets in Array"
Number of Unequal Triplets in Array is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by a senior engineer who knows the OA is theater. This is the script.
Get StealthCoderThe trick here is understanding what unequal triplets really count. A lot of people immediately jump to nested loops or a brute-force comparison of every triple, which tanks performance. Others assume you need to track indices separately from values and miss that you can use a hash table or frequency map to collapse the problem. The constraint that matters, whether indices must be distinct, or values must be distinct, or both, changes the algorithm entirely. Array, Hash Table, and Sorting are all listed as topics, which suggests multiple valid paths: you could sort and binary-search, you could count frequencies and combinatorially derive the answer, or you could filter unique values and count triplets from there. The 70% acceptance rate means most submissions pass, but the ones that fail usually miss the distinction between counting value triplets and index triplets. If you hit this live and the brute force times out, StealthCoder runs invisible during screen share and shows you the hash table or frequency-based solution that works in one pass.
Pattern tags
You know the problem.
Make sure you actually pass it.
Number of Unequal Triplets in Array recycles across companies for a reason. It's easy-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by a senior engineer who knows the OA is theater. This is the script. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Number of Unequal Triplets in Array interview FAQ
What's the actual constraint that makes this not just brute force?+
The problem wants triplets where all three values are different from each other. A lot of people code three nested loops on indices and compare values, which is O(n^3). Once you realize you can count distinct values and their frequencies, the problem collapses to combinatorics or a single hash table pass.
Is this still asked at Paytm and similar companies?+
Paytm has asked it according to reports. It's marked Easy and sits at 72.6% acceptance, so it's not a filter problem for strong candidates but it's definitely in rotation. Expect it more at mid-market or India-based tech companies than at top-tier FAANG shops.
Which approach is fastest: sorting, hash table, or nested loops?+
Hash table or frequency counting is O(n) space and time. Sorting is O(n log n) time. Nested loops are O(n^3) and will time out on large inputs. Hash Table is the practical choice because you can derive the count of unequal triplets from frequencies without iterating through candidates.
What's the common mistake that kills submissions?+
Confusing whether you're counting triplets by index or by value. If you think you need three distinct indices with three distinct values, you code nested loops. If you realize you can just count how many triplets you can make from the distinct values in the array, the solution shrinks dramatically.
How does this relate to the other Array and Hash Table problems?+
It's a warm-up for the category. Array and Hash Table topics cover frequency counting and constraint-based selection. This problem tests whether you can see that a value-frequency map lets you skip iteration. It's easier than Two Sum or Three Sum but teaches the same design pattern.
Want the actual problem statement? View "Number of Unequal Triplets in Array" on LeetCode →