Question: solution fr this pls? oblem Statement are given an array A of length N and a number K. call a subset of in 1]) as

 solution fr this pls? oblem Statement are given an array A

of length N and a number K. call a subset of in

1]) as a good set if: - For any two chosen indices,

solution fr this pls?

oblem Statement are given an array A of length N and a number K. call a subset of in 1]) as a good set if: - For any two chosen indices, i and j in that set the condition (abs(1j)>=K) is satisfied. ets say we have a good set S, now we sort S in ascending order and replace each dex i in sorted set S with the number A[i]. After the replacement if the resulting set S1 in increasing order then we call S a magical set. Find the maximum possible size of a magical set in A. Notes: - A sequence is called an increasing secuence if all the numbers are in increasing order, for example [1,3,4] is an increasing sequence while [1,3,3] is not. - It is given that the function abs(x) means the absolute value of the number x. Input Format The first line contains an integer, N, denoting the number of-elements in A. The next line contains an integer, K, described in the problem statement. Each line i of the N subsequent lines (where 0i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!