Permutation
Practice
3 (8 votes)
Introduction to dynamic programming 2
Algorithms
Medium
Dp
Dynamic programming
Problem
11% Success 787 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

You are given a number N.
Create a set S containing the digits of the number N.(set has only 1 occurence of each element).Using this set create a number X.
Choose a subsequence of indices from the number N and create a number Y.
You need to tell the number of distinct numbers Y that can be created such that X and Y are permutation of each other.

Note: X and Y may have leading 0's.
Constraints

\(1 \le T \le100\)
\(1 \le LengthOf|N| \le 100\)
Each character is digit (i.e '0' to '9'). 

Input Format 

First line contains T (the number of testcases).
Each testcase contains a Number N 

Output Format 
In each line print the number of distinct  possible values of Y.
 

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
Tags:
Medium
Points:30
Tags:
mediumDynamic programmingArrays2dIntroduction to Dynamic Programming-2AlgorithmsMediumDynamic Programming
Points:30
1 votes