Question: You are given an array A of length N and a number M such that M N . It is given that each element in
You are given an array A of length N and a number M such that M N It is given that each element in A is between and M and each number from to M appears at least once in A
Find the maximum lexicographical subsequence permutation in A
Let's assume that the resulting array is P Your task is to print the sum of Pi i modulo e for each i from to M
Input Format
The first line contains an integer, N denoting the number of elements in A
The next line contains an integer, M denoting the given integer.
Each line i of the N subsequent lines where i N contains an integer describing Ai
Constraints
N
Sample Test Cases
Case
Input:
Output:
Explanation:
Given N M A
The resulting array is so the answer is
Case
Input:
Output:
Explanation:
Given N M A matrix matrix
The resulting array is so the answer is
Case
Input:
Output:
Explanation:
Given N M A
The resulting array is so the answer is
int getansint N int M vector A
Write your code here
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
