GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Sunday 3 July 2022

[Solution] K-MEX CodeChef Solution | CodeChef Solution


You are given an array A containing N integers. Find if it is possible to choose exactly M elements from the array such that the MEX of the chosen elements is exactly K.

Recall that the MEX of an array is the smallest non-negative integer that does not belong to the array. For example, the MEX of [2,2,1] is 0 because 0 does not belong to the array, the MEX of [3,1,0,1] is 2 because 0 and 1 belong to the array, but 2 does not.

Input Format

  • The first line contains an integer T, denoting the number of test cases. The T test cases then follow:
Solution Click Below:-  👉CLICK HERE👈
👇👇👇👇👇


  • The first line of each test case contains an integer N,M,K, denoting the length of the array, the number of elements to be chosen, and the required MEX respectively.
  • The second line of each test case contains N space-separated integers A1,A2,,AN, denoting


  •  the elements of the array.

Output Format

For each test case, print YES if it is possible to choose M elements from the array A so that the MEX of the chosen elements is exactly K and NO otherwise.

You may print each character of the string in uppercase or lowercase (for example, the strings yEsyesYes and YES will all be treated as identical).

Constraints

  • 1T100
  • 1N100
  • 1MN

No comments:

Post a Comment