Q1. Given two numbers N and M and an array of size N.
A triplet is defined if it satisfies any one of the following conditions:
Given the array, find the maximum number of triplets that can be formed. All elements of the array are <= M.
Note: Each element of the array can only be a part of one triplet.
Constraints:
1 <= N <= 10^5
1 <= M <= 10^4
1 <= arr[i] <= M
Q2. You are given a string A representing a number. The digits of the number only consists of digits 1 to 9.
You are given an array F that contains a mapping for digits from 1 to 9 i.e, F[i] transforms the digit i to the value of defined in F[i].
You can apply the following operation at-most 1 time:
What is the maximum number you can obtain in this manner? Since the number can be large, output it modulo 10^9 + 7.
Constraints:
1 <= len(A) <= 10^5
1 <= F[i] <= 9
Q3. There is a bag which is full of N numbers from 1 to N. Now your friend decided to split these numbers into 2 other bags (not necessarily equally).
He tells you the sum of numbers in Bag 1 as X and the sum of numbers in Bag 2 as Y.
Your task is to determine the minimum possible count of numbers in Bag 1 whose sum is X? If the scenario is no possible, return -1.
Constraints:
1 <= X <= 10^9
1 <= Y <= 10^9
Sample input 1 : X = 12, Y = 3
output : 3
Sample input 2 : X = 5, Y = 7
output : -1
Edit : Do you want me to post the questions from other slots as well?