Description
Solutions
Count 3 Sister Numbers
👩‍🎓 NEW GRAD

Note - See the problem source section below for the original prompt :)

2000 years ago, in the enchanted land of Numeria, the Numerian Council was tasked with counting a special group of three-digit numbers that lived between left and right, where 100 ≤ left ≤ right ≤ 999. These numbers were unique because each of their three digits was distinct—like three adventurous friends on a quest, none of them alike. The council had to ensure they found all such numbers where no two digits were the same, within the magical range of Numeria. The task did not require the swiftest method, but it needed a solution that wouldn't take longer than right² steps, making sure the story of these numbers could be told efficiently without too much trouble. And so, their journey to count these special heroes began, celebrating each distinct number as a unique part of their magical land.

Example 1:

Input:  l = 876, r = 890
Output: 3
Explanation:
In the enchanted land of Numeria, within the chosen range, three brave numbers stood out from the rest: 876, 879, and 890. These numbers were unlike any others, for each of their digits was pairwise distinct, just like three unique characters on an epic adventure. No digit repeated itself, and together they formed a trio that shone brightly in Numeria’s magical landscape, celebrating their special uniqueness in a way no other numbers could.
Constraints:
  • code>100 <= left <= right <= 999
  • There might be more constraints. I will add them once find more reliable source :)
Thumbnail 0
Thumbnail 1
Testcase

Result
Case 1

input:

output: