GUPTA MECHANICAL

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

Sunday 19 June 2022

[Solution] Max Shift After XOR CodeChef Solution | CodeChef Problem Solution 2022


You are given an array A, consisting of N integers.

Consider the following definitions:

  • Prefix xor array of an array A is defined as the array B such that Bi=A1Ai, where  denotes bitwise XOR operation.
    In other words, B=[A1,A1A2,,A1A2AN]
  • The value of an array A is the number of distinct values in array B. For example, for array A=[1,2,3,0], we have B=[1,3,0,0]. The array B has 3 distinct values, thus, the value of array A is 3.
  • One right shift on the array A is a transformation that changes the array A=[A1,A2,AN] to A=[AN,A1,,AN1].

Solution Click Below:-  CLICK HERE


Calculate the maximum value of the array A you can get, by performing any (possibly zero) number of right shifts on the array A.

Input Format

  • The first line of input contains T  the number of test cases you need to solve.
  • The first line of each test case contains one integer N  the size of the array.
  • The second line of each test case contains N space-separated integers A1,,AN  the

  •  elements of the array A.

Output Format

For each test case, output on a new line the maximum value of an array A you can achieve after performing any (possibly zero) number of right shifts on the array.

Constraints

  • 1T105
  • 2N2105
  • 0Ai2601
  • Sum of N over all test cases doesn't exceed 2105.

No comments:

Post a Comment