GUPTA MECHANICAL

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

Wednesday, 20 July 2022

[Solution] Positive array CodeChef Solution



1-indexed array is called positive if every element of the array is greater than or equal to the index on which it lies. Formally, an array B of size M is called positive if Bii for each 1iM.

For example, the arrays [1],[2,2],[3,2,4,4] are positive while the arrays [2,1],[3,1,2] are not positive.

You are given an array A containing N integers. You want to distribute all elements of the array into some positive arrays. The elements of a positive array might not occur in the order they appear in the array A.

Find the minimum number of positive arrays that the elements of the array A can be divided into.

Solution Click Below:-  👉CLICK HERE👈
👇👇👇👇👇

Please see the sample cases below for more clarity.

Input Format

  • The first line of input will contain a single integer T, denoting the number of test cases.

  • Each test case consists of two lines of input.
    • The first line of each test case contains an integer N — the number of elements in the array A.
    • The next line contains N space-separated integers A1,A2,,AN — the elements of array A.

Output Format

For each test case, output on a new line the minimum number of positive arrays that the elements of the array A can be divided into.​

Constraints

  • 1T104
  • 1N105
  • 1AiN
  • The sum of N over all test cases won't exceed 

No comments:

Post a Comment