maximum sum of array with no repeating digit

You are given an integer array A. find the maximum sum of a subsequence of A such that no digit is repeated in subsequence.

You are allowed to use an integer if it contain multiple digit but you cannot use 2 different integer with same digit.

Note: A sequence S is subsequence of T if S can be generated by removing 0 or more elements from T.

Input Format:

First and only argument of input contains an integer array A of size N.

Output Format:

return a single integer representing the maximum sum.


1 ≤ N ≤ 1000
1 ≤ A[i] ≤ 10^9

For Example:

Input 1:
    A = [25,15,16,99]
Output 1:
Explanation 1:
    If we choose subsequence [25,16,99], there are no repeating digits and sum is maximized among all correct subsequences.
Input 2:
    A = [12,23,13]
Output 2:
Explanation 2:
    Every pair of integer have a digit common. so, we can only choose 1 number.
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving maximum sum of array with no repeating digit on Interview Code Editor
Sign Up
to access hints and editorial solutions for maximum sum of array with no repeating digit


Click here to start solving coding interview questions