Company: Microsoft intern
Difficulty: medium
Maximum Sum of Two Numbers Without Common Digits There is an array A of N integers. What is the largest sum of two numbers which do not have any common digits? Write a function: int solution(vector<int> &A); that, given an array A of length N, returns largest possible sum of two numbers from A which do not have any digits in common. If it is impossible to choose two such numbers, the function should return -1. Examples Example 1: A = [53, 1, 36, 103, 55, 5] The function should return 108, because we could choose numbers 103 and 5. Other pairs of numbers which do not share any digits, for example 3 and 55, total to a smaller sum. Example 2: A = [9, 19, 99, 35] The function should return -1, as every pair of numbers shares the digits. Example 3: A = [6, 17, 71, 65, 17, 6] The function should return 137. The best pair is 71 and 66. Example 4: A = [15, 0, 105] The function should return 15. Constraints N is an integer within the range [2..200,000] each element of array A is an intege