Question 1: Number Game
You're given an Array of 2N +ve integers and N operations. In each operation, you can select any two +ve integers from the array
Your score in each round will be gcd(num1, num2) * operation number, where num1 and num2 are the selected numbers and operation number is the current operation. Your total score will be the sum of all the scores.
Your goal is to maximize the above total score and return the maximum total score
N (No of operations) -> 1 <= N <= 10
1 <= num <= 10^9
Example:
N = 2, Arr = [3,4,9,5]
Max score is 1 * gcd(4,5) + 2 * gcd(3, 9) = 7
Question 2: Substrings and distinct characters
You're given a string S of lower case alphabets. Let Xi be the number of substrings with atleast i distinct characters.
Determine the value of Xi for all i, where i can take values in range [1, 26] (both inclusive)
Constraints:
N (length of S) is upto 5 * 10**5
Examples:
S = aabc
For X1 -> 4 * (5) / 2 -> 10 (No of substrings with atleast 1 distinct characters)
For X2 -> substrings with atleast 2 distinct characters are (aab, aabc, bc, abc, ab) -> 5
For X3 -> substrings with atleast 3 distinct characters are (aabc, abc) -> 2
For Xi where i >= 4, No substrings can have alteast > 4 distinct characters
So, the answer will be [10, 5, 2, 0, 0, 0, 0, 0, 0, ----, 0] (length of the output must be 26 for Xi where i is from 1 to 26)