GUPTA MECHANICAL

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

Thursday 28 July 2022

[Solution] Good Indices CodeChef Solution 2022



Problem

Chef has an array A of length N.

He calls an index i (1 \leq i \leq N) good if there exists some j \neq i such that A_i = A_j.

Chef can perform the following operation at most once:

  • Choose any subsequence of the array A and add any positive integer to all the elements of the chosen subsequence.
Solution Click Below:-  👉CLICK HERE👈
👇👇👇👇👇

Determine the maximum number of good indices Chef can get.

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 a single integer N denoting the length of the array A.
    • The second line contains N space-separated integers denoting the array A.

Output Format

For each test case, output the maximum number of good indices Chef can get after performing the given operation at most once.



No comments:

Post a Comment